Re: [w3c/webcomponents] Non-class based example of customElement.define() (#587)

Aha!! I got it to work with ES5 classes using `Reflect.construct`! Try this in console:

```js
    function Bar() {
      console.log('Bar, new.target:', new.target)
      let _ = Reflect.construct(HTMLElement, [], new.target)
      _.name = _.name + " bar"
      return _
    }

    Bar.prototype = Object.create(HTMLElement.prototype)

    function Baz() {
      console.log('Baz, new.target:', new.target)
      let _ = Reflect.construct(Bar, [], new.target)
      _.name = _.name + " baz"
      return _
    }

    Baz.prototype = Object.create(Bar.prototype)

    Baz.prototype.sayHello = function() {
      return `Hello ${this.localName}!`
    }

    customElements.define('x-baz', Baz)

    const baz = new Baz

    console.log(baz.sayHello())
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/587#issuecomment-271031208

Received on Friday, 6 January 2017 22:47:53 UTC