From f0eb24f46f2a9f546806d638d8fcb07c4cd37831 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Mon, 22 Aug 2016 10:19:28 -0700 Subject: [PATCH 1/8] Remove createShadowRoot() --- src/elements/element.html | 5 ++--- test/smoke/bindings.html | 5 ++--- test/smoke/css-properties.html | 2 +- test/smoke/data-lazy.html | 4 ++-- test/smoke/data-observers.html | 4 ++-- test/smoke/data-path.html | 6 +++--- test/smoke/dom-if.html | 2 +- test/smoke/dom-repeat.html | 2 +- test/smoke/properties-invalidate-be.html | 2 +- test/smoke/properties-invalidate-raw.html | 2 +- test/smoke/properties-invalidate-stampino.html | 2 +- test/smoke/shadow-with-css.html | 2 +- test/smoke/shady-with-css-dynamic.html | 2 +- test/smoke/shady-with-css.html | 2 +- test/smoke/shady.html | 10 +++++----- test/smoke/template-polymer.html | 10 +++++----- test/smoke/template.html | 8 ++++---- test/smoke/templatizer.html | 2 +- test/smoke/utils.html | 2 +- test/unit/styling-cross-scope-unknown-host.html | 6 +----- 20 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/elements/element.html b/src/elements/element.html index d9a07208c3..407c568c6d 100644 --- a/src/elements/element.html +++ b/src/elements/element.html @@ -217,9 +217,8 @@ ready() { if (!this.root) { if (this._template) { - // BREAKME(sorvell): remove v0 support when we can... - this.root = Polymer.shadowDomV0 ? this.createShadowRoot() : - this.attachShadow({mode: 'open'}); + // BREAKME(sorvell): v0 support removed + this.root = this.attachShadow({mode: 'open'}); } else { this.root = this; } diff --git a/test/smoke/bindings.html b/test/smoke/bindings.html index 48451e53a6..fa1a57c064 100644 --- a/test/smoke/bindings.html +++ b/test/smoke/bindings.html @@ -67,7 +67,7 @@ createdCallback() { var dom = document.importNode(template.content, true); propertyEffects.setupBindings(this, dom, notes); - this.createShadowRoot().appendChild(dom); + this.attachShadow({mode:'open'}).appendChild(dom); } concat(a, b) { @@ -90,8 +90,7 @@ createdCallback() { var dom = document.importNode(clientTemplate.content, true); propertyEffects.setupBindings(this, dom, clientNotes); - this.createShadowRoot().appendChild(dom); - //this.attachShadow({mode: 'open'}).appendChild(dom); + this.attachShadow({mode: 'open'}).appendChild(dom); } } diff --git a/test/smoke/css-properties.html b/test/smoke/css-properties.html index 4cb336b2d5..61cec2df2b 100644 --- a/test/smoke/css-properties.html +++ b/test/smoke/css-properties.html @@ -43,7 +43,7 @@ this._styles = [style]; style.remove(); before.textContent = style.textContent; - this.createShadowRoot().appendChild(content); + this.attachShadow({mode:'open'}).appendChild(content); this.root = this.shadowRoot; style = this.style(); let output = this.root.querySelector('#after'); diff --git a/test/smoke/data-lazy.html b/test/smoke/data-lazy.html index 8caa60be41..76194ab0a4 100644 --- a/test/smoke/data-lazy.html +++ b/test/smoke/data-lazy.html @@ -105,7 +105,7 @@ createdCallback() { data.prepare(this, function() { - this.createShadowRoot().appendChild(data.stamp(this, template)) + this.attachShadow({mode:'open'}).appendChild(data.stamp(this, template)) }); if (!this.__registered) { registerXProperties(this.__proto__); @@ -193,7 +193,7 @@ createdCallback() { data.prepare(this, function() { - this.createShadowRoot().appendChild(data.stamp(this, clientTemplate)) + this.attachShadow({mode:'open'}).appendChild(data.stamp(this, clientTemplate)) }); if (!this.__registered) { registerXClient(this.__proto__); diff --git a/test/smoke/data-observers.html b/test/smoke/data-observers.html index 59edce4c3d..e85ed0a8ea 100644 --- a/test/smoke/data-observers.html +++ b/test/smoke/data-observers.html @@ -62,7 +62,7 @@ createdCallback() { this.prop = 'prop'; var dom = data.ensureStamped(this, hostTemplate); - this.createShadowRoot().appendChild(dom); + this.attachShadow({mode:'open'}).appendChild(dom); } _propChanged(value) { console.log('host:', 'propChanged:', value); @@ -87,7 +87,7 @@ class XClient extends HTMLElement { createdCallback() { var dom = data.ensureStamped(this, clientTemplate); - this.createShadowRoot().appendChild(dom); + this.attachShadow({mode:'open'}).appendChild(dom); } _propChanged(value) { console.log('client:', 'propChanged:', value); diff --git a/test/smoke/data-path.html b/test/smoke/data-path.html index 7efc4aa804..b054df516e 100644 --- a/test/smoke/data-path.html +++ b/test/smoke/data-path.html @@ -82,7 +82,7 @@ } createdCallback() { data.prepare(this, function() { - this.createShadowRoot().appendChild(data.stamp(this, objTemplate)); + this.attachShadow({mode:'open'}).appendChild(data.stamp(this, objTemplate)); }); } connectedCallback() { @@ -102,7 +102,7 @@ } createdCallback() { data.prepare(this, function() { - this.createShadowRoot().appendChild(data.stamp(this, propTemplate)); + this.attachShadow({mode:'open'}).appendChild(data.stamp(this, propTemplate)); }); } connectedCallback() { @@ -123,7 +123,7 @@ } createdCallback() { data.prepare(this, function() { - this.createShadowRoot().appendChild(data.stamp(this, hostTemplate)); + this.attachShadow({mode:'open'}).appendChild(data.stamp(this, hostTemplate)); }); this.hdata = { obj1: { diff --git a/test/smoke/dom-if.html b/test/smoke/dom-if.html index 9debfa8a9c..3ec6480c0d 100644 --- a/test/smoke/dom-if.html +++ b/test/smoke/dom-if.html @@ -36,7 +36,7 @@ } createdCallback() { data.prepare(this, function() { - this.createShadowRoot().appendChild(data.stamp(this, template)); + this.attachShadow({mode:'open'}).appendChild(data.stamp(this, template)); }); this.hostProp = 'prop'; } diff --git a/test/smoke/dom-repeat.html b/test/smoke/dom-repeat.html index 79a3e8aa8a..da165398a1 100644 --- a/test/smoke/dom-repeat.html +++ b/test/smoke/dom-repeat.html @@ -42,7 +42,7 @@ createdCallback() { var self = this; data.prepare(this, function() { - this.createShadowRoot().appendChild(data.stamp(this, template)); + this.attachShadow({mode:'open'}).appendChild(data.stamp(this, template)); }); this.items = [ {prop: 'a'}, diff --git a/test/smoke/properties-invalidate-be.html b/test/smoke/properties-invalidate-be.html index 861e140b79..dcbe71a594 100644 --- a/test/smoke/properties-invalidate-be.html +++ b/test/smoke/properties-invalidate-be.html @@ -55,7 +55,7 @@ createdCallback() { attributes.simulateV1AttributeCallbacks(this); this.dom = new XTestDom(); - this.createShadowRoot().appendChild(data.stamp(template, this.dom)); + this.attachShadow({mode:'open'}).appendChild(data.stamp(template, this.dom)); data.enablePropertyEffects(this.dom); } diff --git a/test/smoke/properties-invalidate-raw.html b/test/smoke/properties-invalidate-raw.html index f9754482b7..0d6b614603 100644 --- a/test/smoke/properties-invalidate-raw.html +++ b/test/smoke/properties-invalidate-raw.html @@ -50,7 +50,7 @@ createdCallback() { attributes.simulateV1AttributeCallbacks(this); - this.createShadowRoot().appendChild(document.importNode(template.content, true)); + this.attachShadow({mode:'open'}).appendChild(document.importNode(template.content, true)); } validate(props, oldProps, changedProps) { diff --git a/test/smoke/properties-invalidate-stampino.html b/test/smoke/properties-invalidate-stampino.html index 98714bf27f..79d7aa98c2 100644 --- a/test/smoke/properties-invalidate-stampino.html +++ b/test/smoke/properties-invalidate-stampino.html @@ -56,7 +56,7 @@ createdCallback() { attributes.simulateV1AttributeCallbacks(this); this.dom = new XTestDom(); - this.createShadowRoot().appendChild(data.stamp(template, this.dom)); + this.attachShadow({mode:'open'}).appendChild(data.stamp(template, this.dom)); data.enablePropertyEffects(this.dom); } diff --git a/test/smoke/shadow-with-css.html b/test/smoke/shadow-with-css.html index 45f73a41b0..423b6e0f38 100644 --- a/test/smoke/shadow-with-css.html +++ b/test/smoke/shadow-with-css.html @@ -102,7 +102,7 @@ attachedCallback() { if (!this.__stamped) { this.__stamped = true; - this.createShadowRoot().appendChild( + this.attachShadow({mode:'open'}).appendChild( document.importNode(template.content, true)); } var d = document.createElement('div'); diff --git a/test/smoke/shady-with-css-dynamic.html b/test/smoke/shady-with-css-dynamic.html index 6ee7068593..ab2d84e21c 100644 --- a/test/smoke/shady-with-css-dynamic.html +++ b/test/smoke/shady-with-css-dynamic.html @@ -119,7 +119,7 @@ attachedCallback() { if (!this.__stamped) { this.__stamped = true; - this.createShadowRoot().appendChild( + this.attachShadow({mode:'open'}).appendChild( document.importNode(template.content, true)); } var d = document.createElement('div'); diff --git a/test/smoke/shady-with-css.html b/test/smoke/shady-with-css.html index d76b84af4d..65258bc55c 100644 --- a/test/smoke/shady-with-css.html +++ b/test/smoke/shady-with-css.html @@ -104,7 +104,7 @@ attachedCallback() { if (!this.__stamped) { this.__stamped = true; - this.createShadowRoot().appendChild( + this.attachShadow({mode:'open'}).appendChild( document.importNode(template.content, true)); } var d = document.createElement('div'); diff --git a/test/smoke/shady.html b/test/smoke/shady.html index 110ff50778..fc764b865e 100644 --- a/test/smoke/shady.html +++ b/test/smoke/shady.html @@ -29,7 +29,7 @@
last
- + - + diff --git a/src/compat/custom-style.html b/src/compat/custom-style.html index 7a40709c32..a6523dd95f 100644 --- a/src/compat/custom-style.html +++ b/src/compat/custom-style.html @@ -84,14 +84,7 @@ documentValidationScheduled = false; } - CustomStyle.extends = 'style'; - var name = 'custom-style'; - - if (window.customElements) { - customElements.define(name, CustomStyle); - } else { - CustomStyle = document.registerElement(name, CustomStyle); - } + customElements.define('custom-style', CustomStyle, {extends: 'style'}); })(); diff --git a/src/compat/dom-module.html b/src/compat/dom-module.html index a404762950..4cf9c9ac92 100644 --- a/src/compat/dom-module.html +++ b/src/compat/dom-module.html @@ -100,11 +100,7 @@ // NOTE: Safari can't deal with an ES6 style function named `import` DomModule.prototype.import = DomModule.prototype.__import; - if (window.customElements) { - customElements.define('dom-module', DomModule); - } else { - DomModule = document.registerElement('dom-module', DomModule); - } + customElements.define('dom-module', DomModule); // NOTE: HTMLImports polyfill does not // block scripts on upgrading elements. However, we want to ensure that diff --git a/src/compat/polymer-fn.html b/src/compat/polymer-fn.html index 08ec7aa0be..10782a1878 100644 --- a/src/compat/polymer-fn.html +++ b/src/compat/polymer-fn.html @@ -33,12 +33,8 @@ if (klass.extends) { options.extends = klass.extends; } - if (window.customElements) { - customElements.define(klass.is, klass, options); - return klass; - } else { - return document.registerElement(klass.prototype.is, klass); - } + customElements.define(klass.is, klass, options); + return klass; }; if (userPolymer) { @@ -48,7 +44,7 @@ } // TODO(sorvel): ad hoc settings... - Polymer.shadowDomV0 = Polymer.shadowDomV0 || + Polymer.shadowDomV0 = Polymer.shadowDomV0 || (location.search.indexOf('shadowDomV0=true') >= 0); })(); diff --git a/src/templatizer/dom-bind.html b/src/templatizer/dom-bind.html index ad68bb4bae..00d7ea419e 100644 --- a/src/templatizer/dom-bind.html +++ b/src/templatizer/dom-bind.html @@ -74,11 +74,7 @@ } - if (window.customElements) { - customElements.define('dom-bind', DomBind); - } else { - DomBind = document.registerElement('dom-bind', DomBind); - } + customElements.define('dom-bind', DomBind); })(); diff --git a/test/smoke/attributes-polymer.html b/test/smoke/attributes-polymer.html index 87d16e691c..367b02c525 100644 --- a/test/smoke/attributes-polymer.html +++ b/test/smoke/attributes-polymer.html @@ -16,16 +16,16 @@ - + - + diff --git a/test/smoke/bindings.html b/test/smoke/bindings.html index fa1a57c064..5c20fd4a84 100644 --- a/test/smoke/bindings.html +++ b/test/smoke/bindings.html @@ -78,7 +78,7 @@ propertyEffects.bindTemplate(XBindings, template); - document.registerElement('x-bindings', XBindings); + customElements.define('x-bindings', XBindings); /////////////// @@ -99,7 +99,7 @@ propertyEffects.createNotifyingProperty(XClient, 'prop'); propertyEffects.bindTemplate(XClient, clientTemplate); - document.registerElement('x-client', XClient); + customElements.define('x-client', XClient); })(); diff --git a/test/smoke/css-properties.html b/test/smoke/css-properties.html index 61cec2df2b..ac6bfd0baf 100644 --- a/test/smoke/css-properties.html +++ b/test/smoke/css-properties.html @@ -105,6 +105,6 @@ XFoo.prototype.is = 'x-foo'; XFoo.prototype.mixin = Polymer.Utils.mixin; -document.registerElement('x-foo', XFoo); +customElements.define('x-foo', XFoo); document.body.appendChild(document.createElement('x-foo')); diff --git a/test/smoke/data-lazy.html b/test/smoke/data-lazy.html index 76194ab0a4..eab50b8a39 100644 --- a/test/smoke/data-lazy.html +++ b/test/smoke/data-lazy.html @@ -165,7 +165,7 @@ } - document.registerElement('x-properties', XProperties); + customElements.define('x-properties', XProperties); // --------------- @@ -247,7 +247,7 @@ } - document.registerElement('x-client', XClient); + customElements.define('x-client', XClient); // --------------- @@ -274,7 +274,7 @@ data.createObserver(XPropertiesSub, 'foo', 'fooChanged2'); - document.registerElement('x-properties-sub', XPropertiesSub); + customElements.define('x-properties-sub', XPropertiesSub); })(); diff --git a/test/smoke/data-observers.html b/test/smoke/data-observers.html index e85ed0a8ea..8da5dd6940 100644 --- a/test/smoke/data-observers.html +++ b/test/smoke/data-observers.html @@ -79,7 +79,7 @@ data.createObserver(XHost, 'prop2', '_prop2Changed'); data.createObserver(XHost, 'prop3', '_prop3Changed'); data.bindTemplate(XHost, hostTemplate); - document.registerElement('x-host', XHost); + customElements.define('x-host', XHost); // --------------- @@ -106,7 +106,7 @@ data.createObserver(XClient, 'prop2', '_prop2Changed'); data.createObserver(XClient, 'prop3', '_prop3Changed'); data.bindTemplate(XClient, clientTemplate); - document.registerElement('x-client', XClient); + customElements.define('x-client', XClient); })(); diff --git a/test/smoke/data-path.html b/test/smoke/data-path.html index b054df516e..862c782b6a 100644 --- a/test/smoke/data-path.html +++ b/test/smoke/data-path.html @@ -93,7 +93,7 @@ } } data.bindTemplate(XObj, objTemplate); - document.registerElement('x-obj', XObj); + customElements.define('x-obj', XObj); var propTemplate = document.querySelector('template#x-prop'); class XProp extends HTMLElement { @@ -114,7 +114,7 @@ } data.bindTemplate(XProp, propTemplate); data.createNotifyingProperty(XProp, 'prop'); - document.registerElement('x-prop', XProp); + customElements.define('x-prop', XProp); var hostTemplate = document.querySelector('template#x-host'); class XHost extends HTMLElement { @@ -142,7 +142,7 @@ } } data.bindTemplate(XHost, hostTemplate); - document.registerElement('x-host', XHost); + customElements.define('x-host', XHost); })(); diff --git a/test/smoke/data.html b/test/smoke/data.html index d1f1655eb6..d4c3f85dee 100644 --- a/test/smoke/data.html +++ b/test/smoke/data.html @@ -160,7 +160,7 @@ data.bindTemplate(XHost, template); - document.registerElement('x-host', XHost); + customElements.define('x-host', XHost); // --------------- diff --git a/test/smoke/dom-if.html b/test/smoke/dom-if.html index 3ec6480c0d..ce02573d98 100644 --- a/test/smoke/dom-if.html +++ b/test/smoke/dom-if.html @@ -50,7 +50,7 @@ data.bindTemplate(XHost, template); - document.registerElement('x-host', XHost); + customElements.define('x-host', XHost); diff --git a/test/smoke/dom-repeat.html b/test/smoke/dom-repeat.html index da165398a1..677831e242 100644 --- a/test/smoke/dom-repeat.html +++ b/test/smoke/dom-repeat.html @@ -60,7 +60,7 @@ data.bindTemplate(XHost, template); - document.registerElement('x-host', XHost); + customElements.define('x-host', XHost); }); diff --git a/test/smoke/events-polymer.html b/test/smoke/events-polymer.html index c5a0a6a146..2e5c262799 100644 --- a/test/smoke/events-polymer.html +++ b/test/smoke/events-polymer.html @@ -21,9 +21,9 @@ 'use strict'; var Events = new Polymer.GestureEventListeners(); - + class XBase extends HTMLElement { - + createdCallback() { this.textContent = this.localName; Events.addMethodListener(this, 'tap', '_tap'); @@ -35,19 +35,19 @@ } - document.registerElement('x-base', XBase); + customElements.define('x-base', XBase); // ********************* // working up to this... Polymer({ - + is: 'x-polymer', listeners: { tap: '_tap' }, - + created: function() { this.textContent = this.localName; this.listen(this, 'custom', '_custom'); @@ -63,7 +63,7 @@ } }); - + })(); diff --git a/test/smoke/events.html b/test/smoke/events.html index 72dc616d93..f68f7e55b8 100644 --- a/test/smoke/events.html +++ b/test/smoke/events.html @@ -17,15 +17,15 @@ - + diff --git a/test/smoke/polymer.html b/test/smoke/polymer.html index 656bbe4378..16b2479063 100644 --- a/test/smoke/polymer.html +++ b/test/smoke/polymer.html @@ -38,11 +38,7 @@ }; - if (window.customElements) { - customElements.define('x-base', XBase); - } else { - XBase = document.registerElement('x-base', XBase); - } + customElements.define('x-base', XBase); class XExtend extends XBase { @@ -62,11 +58,7 @@ }; - if (window.customElements) { - customElements.define('x-extend', XExtend); - } else { - XExtend = document.registerElement('x-extend', XExtend); - } + customElements.define('x-extend', XExtend); // ********************* diff --git a/test/smoke/properties-invalidate-be.html b/test/smoke/properties-invalidate-be.html index dcbe71a594..3dbdfa335c 100644 --- a/test/smoke/properties-invalidate-be.html +++ b/test/smoke/properties-invalidate-be.html @@ -74,7 +74,7 @@ class XTestDom {}; data.bindTemplate(XTestDom, template); - document.registerElement('x-test', XTest); + customElements.define('x-test', XTest); })(); diff --git a/test/smoke/properties-invalidate-raw.html b/test/smoke/properties-invalidate-raw.html index 0d6b614603..08259eaec1 100644 --- a/test/smoke/properties-invalidate-raw.html +++ b/test/smoke/properties-invalidate-raw.html @@ -70,7 +70,7 @@ accessors.createAcessorsForAttributes(XTest); - document.registerElement('x-test', XTest); + customElements.define('x-test', XTest); })(); diff --git a/test/smoke/properties-invalidate-stampino.html b/test/smoke/properties-invalidate-stampino.html index 79d7aa98c2..b423b355c7 100644 --- a/test/smoke/properties-invalidate-stampino.html +++ b/test/smoke/properties-invalidate-stampino.html @@ -75,7 +75,7 @@ class XTestDom {}; data.bindTemplate(XTestDom, template); - document.registerElement('x-test', XTest); + customElements.define('x-test', XTest); })(); diff --git a/test/smoke/properties-invalidate.html b/test/smoke/properties-invalidate.html index c8df1e39f9..e0c18207ca 100644 --- a/test/smoke/properties-invalidate.html +++ b/test/smoke/properties-invalidate.html @@ -53,7 +53,7 @@ accessors.createAcessorsForAttributes(XTest); - document.registerElement('x-test', XTest); + customElements.define('x-test', XTest); })(); diff --git a/test/smoke/properties.html b/test/smoke/properties.html index 699cdd68c4..7bc0d1b777 100644 --- a/test/smoke/properties.html +++ b/test/smoke/properties.html @@ -105,7 +105,7 @@ // Polymer.Bindings.createBindings(XProperties, notes); - document.registerElement('x-properties', XProperties); + customElements.define('x-properties', XProperties); // --------------- @@ -132,7 +132,7 @@ PropertyEffects.createObserver(XPropertiesSub, 'foo', 'fooChanged2'); - document.registerElement('x-properties-sub', XPropertiesSub); + customElements.define('x-properties-sub', XPropertiesSub); })(); diff --git a/test/smoke/shadow-with-css.html b/test/smoke/shadow-with-css.html index 423b6e0f38..821367bba0 100644 --- a/test/smoke/shadow-with-css.html +++ b/test/smoke/shadow-with-css.html @@ -75,7 +75,7 @@ } - document.registerElement('x-base-v1', XBaseV1); + customElements.define('x-base-v1', XBaseV1); }); @@ -112,7 +112,7 @@ } - document.registerElement('x-base-v0', XBaseV0); + customElements.define('x-base-v0', XBaseV0); }); @@ -154,7 +154,7 @@ } } } - document.registerElement('x-child', XChild); + customElements.define('x-child', XChild); }); - +