Skip to content

Commit

Permalink
[BUG] infinite loop when not embeded...
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed Jan 12, 2022
1 parent 47eebf5 commit e1e3a6b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions dist/extra/IFrameAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ol.ext.IFrameAPI = function(targetOrigin) {
this.setter = {};
// Listener api
this.listener = {};
// Nothing to do there
if (window.parent === window) return;
// Wait for target ready
window.addEventListener('message', function(e) {
if (e.data.listener) {
Expand Down
4 changes: 2 additions & 2 deletions dist/extra/MapIFrameAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var MapIFrameAPI = function(win, id, targetOrigin) {
* @param {Object|function} data argments or a callback function to get returned Transferable
* @param {function} fn callback function to get returned Transferable
*/
MapIFrameAPI.prototype.call = function(key, data, fn) {
MapIFrameAPI.prototype.call = function(key, data, fn) {
if (typeof(data)==='function') {
fn = data;
data = undefined;
Expand Down Expand Up @@ -91,7 +91,7 @@ var MapIFrameAPI = function(win, id, targetOrigin) {
* @param {function} fn callback function
* @return {function} IFrameListener
*/
MapIFrameAPI.prototype.addIFrameListener = function(key, fn, data) {
MapIFrameAPI.prototype.addIFrameListener = function(key, fn, data) {
var callback = function(e) {
if (e.data.id === this.id && e.data.api === key) {
fn.call(this, e.data.data);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/IFrameAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var ol_ext_IFrameAPI = function(targetOrigin) {
this.setter = {};
// Listener api
this.listener = {};
// Nothing to do there
if (window.parent === window) return;
// Wait for target ready
window.addEventListener('message', function(e) {
if (e.data.listener) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/MapIFrameAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var MapIFrameAPI = function(win, id, targetOrigin) {
* @param {Object|function} data argments or a callback function to get returned Transferable
* @param {function} fn callback function to get returned Transferable
*/
MapIFrameAPI.prototype.call = function(key, data, fn) {
MapIFrameAPI.prototype.call = function(key, data, fn) {
if (typeof(data)==='function') {
fn = data;
data = undefined;
Expand Down Expand Up @@ -93,7 +93,7 @@ var MapIFrameAPI = function(win, id, targetOrigin) {
* @param {function} fn callback function
* @return {function} IFrameListener
*/
MapIFrameAPI.prototype.addIFrameListener = function(key, fn, data) {
MapIFrameAPI.prototype.addIFrameListener = function(key, fn, data) {
var callback = function(e) {
if (e.data.id === this.id && e.data.api === key) {
fn.call(this, e.data.data);
Expand Down

0 comments on commit e1e3a6b

Please sign in to comment.