remove HTMLImports stub

This commit is contained in:
valdrinkoshi
2017-02-14 17:40:21 -08:00
parent 544935fc2e
commit 2918670bcd
5 changed files with 7 additions and 33 deletions

View File

@@ -26,7 +26,7 @@
// order expected
assert.deepEqual(a1DocsList, ['a1-instance.html', 'a1-reference.html']);
// style applied at upgrade time
if (!HTMLImports.useNative) {
if (window.HTMLImports) {
assert.isTrue(styleAppliedToDocument);
}
done();

View File

@@ -26,11 +26,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
link.rel = 'import';
link.href = 'imports/element-import.html';
document.head.appendChild(link);
HTMLImports.whenReady(function() {
link.addEventListener('load', function() {
assert.isTrue(xfoo.isCreated, 'element in main document, registered in dynamic import is upgraded');
var ix = link.import.querySelector('x-foo');
assert.equal(HTMLImports.importForElement(ix), link.import, 'import for element should be link import');
assert.isTrue(ix.isCreated, 'element in import, registered in dynamic import is upgraded');
done();
});

View File

@@ -38,7 +38,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
test('upgraded document tree', function(done) {
if (CustomElements.useNative || HTMLImports.useNative) {
if (CustomElements.useNative || !window.HTMLImports) {
return done();
} else {
window.addEventListener('WebComponentsReady', function() {

View File

@@ -30,7 +30,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
suite('Loader', function() {
test('expected boot', function() {
assert.equal(window.webComponentsReadyCount, 1, 'failed to fire WebComponentsReady');
if (!window.HTMLImports.useNative) {
if (window.HTMLImports) {
assert.ok(window.importsOk, 'WebComponentsReady without HTMLImportsLoaded');
}
assert.ok(window.importTest, 'import failed to set global value');

View File

@@ -11,29 +11,7 @@
(function() {
// Feature detect which polyfill needs to be imported.
let polyfills = [];
if ('import' in document.createElement('link')) {
// Stub out HTMLImports if we're using native imports.
window.HTMLImports = {
useNative: true,
importForElement: function(el) {
return el.ownerDocument !== document ? el.ownerDocument : null;
},
whenReady: function(callback) {
// When native imports boot, the are "ready" the first rAF after
// the document becomes interactive, so wait for the correct state change.
if (document.readyState === 'loading') {
document.addEventListener('readystatechange', function once() {
document.removeEventListener('readystatechange', once);
HTMLImports.whenReady(callback);
});
} else if (document.readyState === 'interactive') {
requestAnimationFrame(callback);
} else {
callback();
}
}
};
} else {
if (!('import' in document.createElement('link'))) {
polyfills.push('hi');
}
if (!('attachShadow' in Element.prototype) || (window.ShadyDOM && window.ShadyDOM.force)) {
@@ -69,10 +47,8 @@
// is removed. Addressing this is blocked on
// https://github.com/webcomponents/shadycss/issues/46.
if (polyfills[0] === 'none') {
HTMLImports.whenReady(function() {
requestAnimationFrame(function() {
window.dispatchEvent(new CustomEvent('WebComponentsReady'));
});
requestAnimationFrame(function() {
window.dispatchEvent(new CustomEvent('WebComponentsReady'));
});
}
})();