From f436c792a0ed563739b2a7356a4c995f83a3586b Mon Sep 17 00:00:00 2001 From: Ben Sheffield Date: Sun, 19 Aug 2018 13:24:06 +0100 Subject: [PATCH 1/2] fix: CustomElement constructor for compatibility with other polyfills (See https://github.com/WebReflection/document-register-element/issues/148) --- src/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index 52741ac..667d339 100644 --- a/src/index.js +++ b/src/index.js @@ -79,14 +79,14 @@ export default function wrap (Vue, Component) { } class CustomElement extends HTMLElement { - constructor () { - super() - this.attachShadow({ mode: 'open' }) + constructor (...args) { + const self = super(...args) + self.attachShadow({ mode: 'open' }) - const wrapper = this._wrapper = new Vue({ + const wrapper = self._wrapper = new Vue({ name: 'shadow-root', - customElement: this, - shadowRoot: this.shadowRoot, + customElement: self, + shadowRoot: self.shadowRoot, data () { return { props: {}, @@ -106,8 +106,8 @@ export default function wrap (Vue, Component) { let hasChildrenChange = false for (let i = 0; i < mutations.length; i++) { const m = mutations[i] - if (isInitialized && m.type === 'attributes' && m.target === this) { - syncAttribute(this, m.attributeName) + if (isInitialized && m.type === 'attributes' && m.target === self) { + syncAttribute(self, m.attributeName) } else { hasChildrenChange = true } @@ -115,11 +115,11 @@ export default function wrap (Vue, Component) { if (hasChildrenChange) { wrapper.slotChildren = Object.freeze(toVNodes( wrapper.$createElement, - this.childNodes + self.childNodes )) } }) - observer.observe(this, { + observer.observe(self, { childList: true, subtree: true, characterData: true, From 94ef1842543945e80e60265095bbe1fa1d6b2a65 Mon Sep 17 00:00:00 2001 From: Ben Sheffield Date: Mon, 20 Aug 2018 18:21:00 +0100 Subject: [PATCH 2/2] fix: remove ...args from CustomElement constructor (See https://html.spec.whatwg.org/#custom-element-conformance) --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 667d339..4409bd7 100644 --- a/src/index.js +++ b/src/index.js @@ -79,8 +79,8 @@ export default function wrap (Vue, Component) { } class CustomElement extends HTMLElement { - constructor (...args) { - const self = super(...args) + constructor () { + const self = super() self.attachShadow({ mode: 'open' }) const wrapper = self._wrapper = new Vue({