Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ if (!domIsReady) {
* If functions are added after this event then they will be executed immediately.
* @param {function} fn The function to add
* @param {Object} scope An optional scope for the function to be called with.
* @param {Boolean} immediate An optional boolean indicating whether to not wait for domIsReady
*/
function whenReady(fn, scope){
if (domIsReady) {
function whenReady(fn, scope, immediate){
if (domIsReady || immediate) {
fn.call(scope);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/stack/FlashTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ easyXDM.stack.FlashTransport = function(config){
}
},
init: function(){
whenReady(pub.onDOMReady, pub);
whenReady(pub.onDOMReady, pub, config.immediate);
}
});
};
2 changes: 1 addition & 1 deletion src/stack/FrameElementTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ easyXDM.stack.FrameElementTransport = function(config){
}
},
init: function(){
whenReady(pub.onDOMReady, pub);
whenReady(pub.onDOMReady, pub, config.immediate);
}
});
};
2 changes: 1 addition & 1 deletion src/stack/HashTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ easyXDM.stack.HashTransport = function(config){
}
},
init: function(){
whenReady(pub.onDOMReady, pub);
whenReady(pub.onDOMReady, pub, config.immediate);
}
});
};
2 changes: 1 addition & 1 deletion src/stack/NameTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ easyXDM.stack.NameTransport = function(config){
});
},
init: function(){
whenReady(pub.onDOMReady, pub);
whenReady(pub.onDOMReady, pub, config.immediate);
}
});
};
2 changes: 1 addition & 1 deletion src/stack/PostMessageTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ easyXDM.stack.PostMessageTransport = function(config){
}
},
init: function(){
whenReady(pub.onDOMReady, pub);
whenReady(pub.onDOMReady, pub, config.immediate);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that if the transports need to be aware of this flag, and that no down-stream code cares about it, then the decision whether to run immediately or to wait for whenReady should also be made here.
This does mean some code duplication though..

}
});
};
2 changes: 1 addition & 1 deletion src/stack/SameOriginTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ easyXDM.stack.SameOriginTransport = function(config){
}
},
init: function(){
whenReady(pub.onDOMReady, pub);
whenReady(pub.onDOMReady, pub, config.immediate);
}
});
};