[w3c/webcomponents] [idea] making builtin elements more like custom elements (#785)

If you imagine builtin elements as having the same underlying building blocks as custom elements (i.e. the Web Manifesto explains builtins, and we can do the same stuff in custom elements), then one would think that we could do the following:

```js
const oldConnectedCallback = HTMLVideoElement.prototype.connectedCallback

HTMLVideoElement.prototype.connectedCallback = function() {
  oldConnectedCallback.call(this)

  // ... do something any time a video element is connected ...
}
```

I think it'd be nice if this were possible.

This would make it simple to implement a lot of stuff. For example a `childConnectedCallback` (described in https://github.com/w3c/webcomponents/issues/550) could be easy:

```js
const oldConnectedCallback = HTMLElement.prototype.connectedCallback

HTMLElement.prototype.connectedCallback = function() {
  oldConnectedCallback.call(this)
  this.parentElement.childConnectedCallback && this.parentElement.childConnectedCallback(this)
}
```

Would it be easy to move existing logic of builtin elements into lifecycle methods without breaking existing sites?

-- 
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/785

Received on Monday, 28 January 2019 03:46:20 UTC