- From: Russell Bicknell <notifications@github.com>
- Date: Thu, 08 Jun 2017 15:48:53 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/583/307248269@github.com>
@trusktr
If we let authors override `setAttribute`, for example, in a custom element definition but the parser doesn't call their element's `setAttribute` while constructing trees, then we can't ever define tree construction that way because authors will already have written code assuming that the parser doesn't do this. I don't want authors to be able to rely on that assumption and prevent that redefinition.
---
It's important to note that this behavior currently is observable *without* being able to define custom elements but it's fairly unusual. For example:
```html
<div>
<script>
const parentNode = document.currentScript.parentNode;
const overriddenMethod = parentNode.insertBefore;
parentNode.insertBefore = function(...args) {
console.log("This will never be logged.");
return overriddenMethod.call(this, ...args);
};
</script>
<div>The `insertBefore` above is never called with this child.</div>
</div>
```
or
```javascript
const elt = document.createElement('div');
const overriddenMethod = elt.setAttribute;
elt.setAttribute = function(...args) {
console.log("This will never be logged.");
return overriddenMethod.call(this, ...args);
};
elt.id = "abc"; // The `setAttribute` above isn't called when `id` is set.
```
However, I suspect that authors don't do this kind of thing particularly often and this behavior might be breakable without much consequence. Maybe this assumption isn't correct?
--
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-307248269
Received on Thursday, 8 June 2017 22:49:55 UTC