WebReflection / document-register-element

A stand-alone working lightweight version of the W3C Custom Elements specification
ISC License
1.13k stars 116 forks source link

Not compatible with vue-web-component-wrapper? #148

Closed zoeyfyi closed 6 years ago

zoeyfyi commented 6 years ago

Due to https://github.com/WebReflection/document-register-element/tree/master#v1-caveat this polyfill doesn't work with https://github.com/vuejs/vue-web-component-wrapper.

class CustomElement extends HTMLElement {
    constructor () {
        super()
        this.attachShadow({ mode: 'open' })

        const wrapper = this._wrapper = new Vue({

(from src/index.js line 81)

Since it does work with https://github.com/webcomponents/webcomponentsjs I was wondering if their is a potential fix.

WebReflection commented 6 years ago

As explained in there:

class CustomElement extends HTMLElement {
    constructor () {
        const self = super()
        self.attachShadow({ mode: 'open' })

        const wrapper = self._wrapper = new Vue({
    ...
    return self;
  }

Be aware this polyfill doesn't provide Shadow DOM neither, so you might use attachshadow or simply stick with webcomponentsjs

zoeyfyi commented 6 years ago

Yeah that's what I had done but I was trying to avoid forking vue-web-component-wrapper.

Thanks anyway

WebReflection commented 6 years ago

I was trying to avoid forking vue-web-component-wrapper

they are ignoring how super() works, which might return a different instance as per specifications.

I'd rather file a bug to their current code than forking it 'cause it won't break anywhere but it will work better in any sort of native constructors patches.

WebReflection commented 6 years ago

P.S. the exact fix should be ...

class CustomElement extends HTMLElement {
    constructor (...args) {
        const self = super(...args)