Skip to content

Commit

Permalink
Child connect now works after the DOM is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Karl committed Mar 12, 2015
1 parent 7aa3eb7 commit ba1d751
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bellhop",
"version": "1.1.4",
"version": "1.1.5",
"main": "dist/bellhop.min.js",
"dependencies": {
"bind-polyfill": "*"
Expand Down
17 changes: 13 additions & 4 deletions dist/bellhop.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,20 @@
}
else
{
// Wait until the window is finished loading
// then send the handshake to the parent
window.onload = function(){
// If connect is called after the window is ready
// we can go ahead and send the connect message
if (window.document.readyState === "complete")
{
target.postMessage('connected', this.origin);
}.bind(this);
}
else
{
// Or wait until the window is finished loading
// then send the handshake to the parent
window.onload = function(){
target.postMessage('connected', this.origin);
}.bind(this);
}
}
}
return this;
Expand Down
2 changes: 1 addition & 1 deletion dist/bellhop.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bellhop",
"version": "1.1.4",
"version": "1.1.5",
"description": "Javascript event-based communication layer between DOM and iframe.",
"url": "https://github.com/CloudKidStudio/Bellhop",
"output": "bellhop",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "1.1.4",
"version": "1.1.5",
"dependencies": {
"grunt": "~0.4.5",
"library-grunt": "*"
Expand Down
17 changes: 13 additions & 4 deletions src/Bellhop.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,20 @@
}
else
{
// Wait until the window is finished loading
// then send the handshake to the parent
window.onload = function(){
// If connect is called after the window is ready
// we can go ahead and send the connect message
if (window.document.readyState === "complete")
{
target.postMessage('connected', this.origin);
}.bind(this);
}
else
{
// Or wait until the window is finished loading
// then send the handshake to the parent
window.onload = function(){
target.postMessage('connected', this.origin);
}.bind(this);
}
}
}
return this;
Expand Down

0 comments on commit ba1d751

Please sign in to comment.