Re: [w3c/webcomponents] [idea] Make use of `observedAttributes` optional (#565)

@rniwa, your previous thought of avoiding invoking JS is not really solving performance. Instead of the end user's conditional statements running logic for certain attributes, we've merely moved that logic into the HTML engine, so now the HTML engine has to conditionally check `observedAttributes` in order to fire the end user's `attributeChangedCallback`. This practically does nothing to improve performance, because regardless of whether the HTML engine checks observedAttributes or not, the user will still have some code like follows:

```js
attributeChangedCallback (a, o, n) {
  if (a == 'foo') { ... }
  else if (a == 'bar') { ... }
  else if (a == 'baz') { ... }
  // etc...
}
```

So the only thing being saved is some extra no-op function calls that will do nothing because most people will already be checking conditionally for certain attributes.

Is there really a significant gain from observedAttributes that outweighs the burden of having to remember to manually list all observed attributes? Are there benchmarks somewhere?

-- 
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/565#issuecomment-345559336

Received on Sunday, 19 November 2017 23:28:22 UTC