Re: [w3c/webcomponents] Custom Element - untrackable upgrade (#671)

The snippet I use to work around this as a custom element author is:

```js
connectedCallback() {
  ...
  this._upgradeProperty('checked');
}

_upgradeProperty(prop) {
  if (this.hasOwnProperty(prop)) {
    let value = this[prop];
    delete this[prop];
    this[prop] = value;
  }
}
```

[Documented a bit more here](https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties) under the heading "Make properties lazy".

I agree this is a tricky gotcha and we ran headlong into it while working on [howto-components](https://github.com/GoogleChromeLabs/howto-components).

-- 
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/671#issuecomment-333004822

Received on Friday, 29 September 2017 01:15:56 UTC