From 50ba9cea2b6034b33c283da88a6d0022aca6dfed Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 14 Feb 2019 14:19:51 -0800 Subject: [PATCH 01/11] Use `ShadyDOM.upgrade` This is a more optimized way to create and populate a `shadowRoot`. --- lib/mixins/element-mixin.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index c931fb7fc0..a8dbc8ab14 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -672,9 +672,13 @@ export const ElementMixin = dedupingMixin(base => { if (n.attachShadow) { if (dom) { if (!n.shadowRoot) { - n.attachShadow({mode: 'open'}); + if (window.ShadyDOM) { + ShadyDOM.upgrade(dom, this, {mode: 'open'}); + } else { + n.attachShadow({mode: 'open'}); + n.shadowRoot.appendChild(dom); + } } - n.shadowRoot.appendChild(dom); if (syncInitialRender && window.ShadyDOM) { ShadyDOM.flushInitial(n.shadowRoot); } From 1aeaa8016f9baa34af845d2371cbf0b5856c5266 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 20 Feb 2019 14:40:34 -0800 Subject: [PATCH 02/11] Use correct ShadyDOM API: `attachDom` --- lib/mixins/element-mixin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index a8dbc8ab14..8ba0fab5a4 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -673,7 +673,7 @@ export const ElementMixin = dedupingMixin(base => { if (dom) { if (!n.shadowRoot) { if (window.ShadyDOM) { - ShadyDOM.upgrade(dom, this, {mode: 'open'}); + ShadyDOM['attachDom'](dom, this, {mode: 'open'}); } else { n.attachShadow({mode: 'open'}); n.shadowRoot.appendChild(dom); From 65a5b48c38be5866a9e9d2e450218ed7f739aadc Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 10 Apr 2019 14:47:39 -0700 Subject: [PATCH 03/11] Avoid upgrading template if no hostProps, for better perf. --- lib/utils/templatize.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utils/templatize.js b/lib/utils/templatize.js index 9f05135470..7cdcb8ca4a 100644 --- a/lib/utils/templatize.js +++ b/lib/utils/templatize.js @@ -364,7 +364,11 @@ function createTemplatizerClass(template, templateInfo, options) { */ function addPropagateEffects(template, templateInfo, options) { let userForwardHostProp = options.forwardHostProp; - if (userForwardHostProp) { + const hasHostProps = templateInfo.hasHostProps || + (templateInfo.hasHostProps = + Boolean(templateInfo.hostProps && + Object.keys(templateInfo.hostProps).length)); + if (userForwardHostProp && hasHostProps) { // Provide data API and property effects on memoized template class let klass = templateInfo.templatizeTemplateClass; if (!klass) { From f1a9d4fa8694e246d7d1cf11b87e11de1a231ac3 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 10 Apr 2019 14:55:40 -0700 Subject: [PATCH 04/11] Simplify --- lib/utils/templatize.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/utils/templatize.js b/lib/utils/templatize.js index 7cdcb8ca4a..859c8a2f8c 100644 --- a/lib/utils/templatize.js +++ b/lib/utils/templatize.js @@ -364,11 +364,7 @@ function createTemplatizerClass(template, templateInfo, options) { */ function addPropagateEffects(template, templateInfo, options) { let userForwardHostProp = options.forwardHostProp; - const hasHostProps = templateInfo.hasHostProps || - (templateInfo.hasHostProps = - Boolean(templateInfo.hostProps && - Object.keys(templateInfo.hostProps).length)); - if (userForwardHostProp && hasHostProps) { + if (userForwardHostProp && templateInfo.hasHostProps) { // Provide data API and property effects on memoized template class let klass = templateInfo.templatizeTemplateClass; if (!klass) { @@ -427,6 +423,9 @@ function addNotifyEffects(klass, template, templateInfo, options) { } if (options.forwardHostProp && template.__dataHost) { for (let hprop in hostProps) { + if (!templateInfo.hasHostProps) { + templateInfo.hasHostProps = true; + } klass.prototype._addPropertyEffect(hprop, klass.prototype.PROPERTY_EFFECT_TYPES.NOTIFY, {fn: createNotifyHostPropEffect()}); From 8d7def7208a7e94171c6c5c4a8101b8bda9dd7e1 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 10 Apr 2019 16:27:33 -0700 Subject: [PATCH 05/11] don't depend on `attachDom` existing. --- lib/mixins/element-mixin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index e2e6eebc5e..7690978cea 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -672,7 +672,7 @@ export const ElementMixin = dedupingMixin(base => { if (n.attachShadow) { if (dom) { if (!n.shadowRoot) { - if (window.ShadyDOM) { + if (window.ShadyDOM && ShadyDOM['attachDom']) { ShadyDOM['attachDom'](dom, this, {mode: 'open'}); } else { n.attachShadow({mode: 'open'}); From f5a45ebc2d0a5baeee680374785756fc83f3b64f Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Thu, 11 Apr 2019 15:32:33 -0700 Subject: [PATCH 06/11] Ensure wildcard arguments get undefined treatment. Fixes #5428. --- lib/legacy/legacy-data-mixin.js | 3 ++- test/unit/legacy-data.html | 48 +++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/lib/legacy/legacy-data-mixin.js b/lib/legacy/legacy-data-mixin.js index b2a255386d..d3d84088e2 100644 --- a/lib/legacy/legacy-data-mixin.js +++ b/lib/legacy/legacy-data-mixin.js @@ -94,7 +94,8 @@ export const LegacyDataMixin = dedupingMixin(superClass => { // undefined or not. Multi-property observers must have all arguments defined if (this._legacyUndefinedCheck && vals.length > 1) { for (let i=0; i `[${inlineSingleDep}]`); this.computeMulti = sinon.spy((inlineMultiDep1, inlineMultiDep2) => `[${inlineMultiDep1},${inlineMultiDep2}]`); + this.wildcardObserver = sinon.spy(); }, throws() { throw new Error('real error'); @@ -145,6 +149,18 @@ + + + + + + + +