You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Illegal Invocation when calling super methods of subclass ancestors #1
It seems the context of the object is lost somewhere in calling an ancestor's methods.
class A extends HTMLElement {
empty () {
while (this.hasChildNodes()) {
this.removeChild(this.lastChild)
}
}
}
class B extends A {
constructor () {
super()
this.empty()
}
}
customElements.define('b-element', B)
fixBabelClass(A)
fixBabelClass(B)
let b = new B()
As an illustration, note how Chrome prints my b custom element when transpiling/fixing-class, as opposed to native ES6 Chrome.
Activity
WebReflection commentedon Jun 6, 2017
try this instead:
WebReflection commentedon Jun 6, 2017
actually, no.
There are few things here that could go wrong.
To start with the first one, you cannot patch after registering the class, it's impossible to overwrite the registry.
this is upside down
do this instead
Secondly, if you are not using a polyfill upfront nothing will ever work.
You need document-register-element or any other polyfill that works to use Babel and custom elements because these need to patch HTMLElement.
If you have done both things and you still have problems please let me know.