Re: [WICG/webcomponents] add `node.isCustomElement` property (Issue #1080)

> Can you go into detail on what is happening around heuristics? What is being done differently for custom elements that doesn't apply to built-ins?

Thanks, @EisenbergEffect, and yes, the problem is that for native elements you pretty much know all cases. But with custom elements you have no way to know all cases, because they can choose to use a property or an attribute at will. When writing heuristics, the heuristics would be more approximate if you know if something is a custom element or not. 

```js
const setUnknown = (node, name, value) => {
  if (isCustomElement(node)) {
    // custom elements
    name in settersOf(node)
      ? setProperty(node, name, value)
      : setAttribute(node, name, value)
  } else {
    // native elements
    if (typeof value !== 'string' && name in settersOf(node)) {
      setProperty(node, name, value)
    } else {
      setAttribute(node, name, value)
    }
  }
}
```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1080#issuecomment-2417830713
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/1080/2417830713@github.com>

Received on Wednesday, 16 October 2024 20:00:45 UTC