[css-houdini-drafts] [css-typed-om] el.attributeStyleMap.set('display', 'block') does not trigger attributeChangedCallback although style attribute changed. (#996)

trusktr has just created a new issue for https://github.com/w3c/css-houdini-drafts:

== [css-typed-om] el.attributeStyleMap.set('display', 'block') does not trigger attributeChangedCallback although style attribute changed. ==
If I have a custom element like

```js
class MyEl extends HTMLElement {
  static observedAttributes = ['style']
  attributeChangedCallback(attr, oldVal, newVal) { console.log(attr, oldVal, newVal) }
}
customElements.define('my-el', MyEl)
```

I noticed that, in Chrome for example, if I run 

```js
el.setAttribute('style', 'block')
```

`attributeChangedCallback` is called and I see console output.

However if I run

```js
el.attributeStyleMap.set('display', new CSSKeywordValue('block'))
```

then `attributeChangedCallback` is not fired and I see no output. However, I can see the attribute is updated in the element inspector and I can call `el.getAttribute('style')` and see the new value.

Is this expected?

---

Personally I was hoping that modifying `el.attributeStyleMap` would not be reflected back to the DOM attribute, for performance gains. Seems half of that desire is correct in that `attributeChangedCallback` is not triggered.

Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/996 using your GitHub account

Received on Saturday, 25 July 2020 01:05:51 UTC