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

I'm pretty sure to obtain expected result the hypothetical upgrade should be performed as such:

  1. `const kv = Object.keys(el).map(k => { const v = el[k]; delete el[k]; return [k, v]; });`
  2. Perform existing upgrade
  3. `kv.forEach(p => el[p[0]] = p[1]);`

This operation will automatically involve the prototype chain when it comes to setters + frozen own properties won't have any side effect, simply silently ignored.

There is still an outstanding question for me: during that third point the element would still be in a _not fully updated_ state.

How about we keep it simple and we focus just on the `whenDefined(element).then...` bit ?

If we had that, all the primitives to do whatever we want would be available.

We can detect if a node is an upgraded * custom element already and, if not, we can do on user-land the manual drop things, wait for it, add things back procedure.

Having it simple would also make adoption, polyfill, and cross browser portability easier.

* to see if a node is an upgraded custom element
```js
const isCustomElement = el => {
  const name = el.nodeName.toLowerCase();
  if (/^([a-z][\S]*?-[\S]*)$/.test(name)) {
    const Class = customElements.get(RegExp.$1);
    if (Class) return el instanceof Class;
  }
  return false;
};
```




-- 
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-335442899

Received on Tuesday, 10 October 2017 11:28:19 UTC