Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Make polymer load warning throw and work more consistently. Helps add…
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Sep 18, 2014
1 parent 1cd2c95 commit 3fddca9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"build/end-if.js",
"../URL/url.js",
"src/lang.js",
"src/dom.js",
"../HTMLImports/build.json",
"../CustomElements/build.json",
"src/patches-custom-elements.js",
"src/dom.js",
"src/unresolved.js",
"src/module.js"
]
3 changes: 1 addition & 2 deletions platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ function processFlags(flags) {
[
'../URL/url.js',
'src/lang.js',
'src/dom.js',
'../HTMLImports/html-imports.js',
'../CustomElements/custom-elements.js',
'src/patches-custom-elements.js',

'src/dom.js',
// these scripts are loaded in platform.js due to polyfill timing issues
'src/unresolved.js',
'src/module.js'
Expand Down
18 changes: 12 additions & 6 deletions src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,23 @@
elementDeclarations = null;
};

// Once DOMContent has loaded, any main document scripts that depend on
// Polymer() should have run. Calling Polymer() now is an error until
// polymer is imported.
window.addEventListener('DOMContentLoaded', function() {
function installPolymerWarning() {
if (window.Polymer === polymerStub) {
window.Polymer = function() {
console.error('You tried to use polymer without loading it first. To ' +
throw new Error('You tried to use polymer without loading it first. To ' +
'load polymer, <link rel="import" href="' +
'components/polymer/polymer.html">');
};
}
});
}

// Once DOMContent has loaded, any main document scripts that depend on
// Polymer() should have run. Calling Polymer() now is an error until
// polymer is imported.
if (HTMLImports.useNative) {
installPolymerWarning();
} else {
addEventListener('DOMContentLoaded', installPolymerWarning);
}

})(window.Platform);

0 comments on commit 3fddca9

Please sign in to comment.