- From: Russell Bicknell <notifications@github.com>
- Date: Mon, 10 Oct 2016 00:52:48 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/583/252554377@github.com>
So, the custom elements spec allows authors to extend HTMLElement and I can put a `setAttribute` function on my custom element's prototype. However, when HTML containing my custom element and a few attributes gets parsed, my definition of `setAttribute` isn't called. So, there must be another unexposed thing for setting attributes that the browser uses when parsing because it's not just making a call like `element.setAttribute(x, y)`. The intent of this issue was to prevent people from expecting a particular behavior so that it might be possible in the future to do things like define parsing in terms of the public API of the elements being created. However, I get the feeling that this ship might have already sailed if people already regularly do things like put their own `setAttribute` on native elements.
This:
```html
<my-element a="b" c="d"></my-element>
```
doesn't have the same result as this:
```javascript
let e = document.createElement('my-element');
e.setAttribute('a', 'b');
e.setAttribute('c', 'd');
```
if `my-element` is defined as:
```javascript
customElements.define('my-element', class extends HTMLElement {
setAttribute() {
// Do nothing.
}
});
```
--
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/583#issuecomment-252554377
Received on Monday, 10 October 2016 07:53:41 UTC