Skip to content
This repository has been archived by the owner on Jan 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #56 from webcomponents/check-body
Browse files Browse the repository at this point in the history
check if <body> exists
  • Loading branch information
Steve Orvell authored Apr 24, 2017
2 parents e29fd6d + f85595f commit 81381e8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"bower_components"
],
"devDependencies": {
"web-component-tester": "6.0.0-prerelease.3"
"web-component-tester": "^6.0.0-prerelease.3"
}
}
28 changes: 14 additions & 14 deletions html-imports.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 html-imports.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
},
"homepage": "https://webcomponents.org/polyfills",
"devDependencies": {
"google-closure-compiler": "^20170218.0.0",
"google-closure-compiler": "^20170409.0.0",
"gulp": "^3.8.8",
"gulp-sourcemaps": "^2.4.0",
"web-component-tester": "6.0.0-prerelease.3"
"web-component-tester": "^6.0.0-prerelease.3"
}
}
17 changes: 8 additions & 9 deletions src/html-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,17 +593,16 @@
* @param {!function()} callback
*/
const whenDocumentReady = callback => {
if (document.readyState !== 'loading') {
callback();
} else {
const stateChanged = () => {
if (document.readyState !== 'loading') {
document.removeEventListener('readystatechange', stateChanged);
callback();
}
const stateChanged = () => {
// NOTE: Firefox can hit readystate interactive without document.body existing.
// This is anti-spec, but we handle it here anyways by waiting for next change.
if (document.readyState !== 'loading' && !!document.body) {
document.removeEventListener('readystatechange', stateChanged);
callback();
}
document.addEventListener('readystatechange', stateChanged);
}
document.addEventListener('readystatechange', stateChanged);
stateChanged();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<script src="../html-imports.min.js"></script>
<script>
WCT = {
environmentImports: [],
waitFor: function(callback) {
this.HTMLImports.whenReady(callback);
}
Expand Down

0 comments on commit 81381e8

Please sign in to comment.