diff --git a/bower.json b/bower.json index aae3490..05b063c 100644 --- a/bower.json +++ b/bower.json @@ -10,7 +10,8 @@ ], "devDependencies": { "web-component-tester": "^4.0.0", - "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" + "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", + "webcomponentsjs-v1": "webcomponents/webcomponentsjs#v1" }, "main": "test-fixture.html", "ignore": [] diff --git a/test-fixture.html b/test-fixture.html index 37a243e..339b1a6 100644 --- a/test-fixture.html +++ b/test-fixture.html @@ -235,11 +235,18 @@ forcePolyfillAttachedStateSynchrony: function () { // Force synchrony in attachedCallback and detachedCallback where - // implemented, in the event that we are dealing with the async Web - // Components Polyfill. - if (window.CustomElements && window.CustomElements.takeRecords) { + // implemented, in the event that we are dealing with one of these async + // polyfills: + // 1. Web Components CustomElements polyfill (v1 or v0). + if (window.customElements && window.customElements.flush) { + window.customElements.flush(); + } else if (window.CustomElements && window.CustomElements.takeRecords) { window.CustomElements.takeRecords(); } + // 2. ShadyDOM polyfill. + if (window.ShadyDOM) { + window.ShadyDOM.flush(); + } }, collectElementChildren: function (parent) { @@ -313,9 +320,20 @@ }); try { - document.registerElement('test-fixture', { - prototype: TestFixturePrototype - }); + if (window.customElements) { + function TestFixture() { + return ((window.Reflect && Reflect.construct) ? + Reflect.construct(HTMLElement, [], TestFixture) + : HTMLElement.call(this)) || this; + } + TestFixture.prototype = TestFixturePrototype; + TestFixture.prototype.constructor = TestFixture; + customElements.define('test-fixture', TestFixture); + } else { + document.registerElement('test-fixture', { + prototype: TestFixturePrototype + }); + } } catch (e) { if (window.WCT) { console.warn('if you are using WCT, you do not need to manually import test-fixture.html'); diff --git a/test/index.html b/test/index.html index a00d9a2..6366568 100644 --- a/test/index.html +++ b/test/index.html @@ -15,14 +15,15 @@ - - diff --git a/test/test-fixture-v1.html b/test/test-fixture-v1.html new file mode 100644 index 0000000..e7bba84 --- /dev/null +++ b/test/test-fixture-v1.html @@ -0,0 +1,262 @@ + + + + + test-fixture + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/test-fixture.html b/test/test-fixture.html index 00788c8..197bb91 100644 --- a/test/test-fixture.html +++ b/test/test-fixture.html @@ -14,9 +14,9 @@ - +