mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
Merge pull request #360 from webcomponents/fix-354
Fixes #354: remove unnecessary legacy Polymer code from polyfills.
This commit is contained in:
@@ -49,50 +49,4 @@
|
||||
})();
|
||||
}
|
||||
|
||||
// Make a stub for Polymer() for polyfill purposes; under the HTMLImports
|
||||
// polyfill, scripts in the main document run before imports. That means
|
||||
// if (1) polymer is imported and (2) Polymer() is called in the main document
|
||||
// in a script after the import, 2 occurs before 1. We correct this here
|
||||
// by specfiically patching Polymer(); this is not necessary under native
|
||||
// HTMLImports.
|
||||
var elementDeclarations = [];
|
||||
|
||||
var polymerStub = function(name, dictionary) {
|
||||
if ((typeof name !== 'string') && (arguments.length === 1)) {
|
||||
Array.prototype.push.call(arguments, document._currentScript);
|
||||
}
|
||||
elementDeclarations.push(arguments);
|
||||
};
|
||||
window.Polymer = polymerStub;
|
||||
|
||||
// deliver queued delcarations
|
||||
scope.consumeDeclarations = function(callback) {
|
||||
scope.consumeDeclarations = function() {
|
||||
throw 'Possible attempt to load Polymer twice';
|
||||
};
|
||||
if (callback) {
|
||||
callback(elementDeclarations);
|
||||
}
|
||||
elementDeclarations = null;
|
||||
};
|
||||
|
||||
function installPolymerWarning() {
|
||||
if (window.Polymer === polymerStub) {
|
||||
window.Polymer = function() {
|
||||
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 {
|
||||
window.addEventListener('DOMContentLoaded', installPolymerWarning);
|
||||
}
|
||||
|
||||
})(window.WebComponents);
|
||||
|
||||
Reference in New Issue
Block a user