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

@Danny-Engelman  The custom elements API simply reads the property off of the class (constructor). It doesn't matter if it is a getter or not. 

In the past, there was a time when `static observedAttributes = ['style']` was not yet legal JavaScript syntax, and the only options were to use a getter in the class definition (like your second example), or to define it after the class definition like so:

```js
class MyEl extends HTMLElement { /* ... */ }

// This is also another way to define a "static" property on a class.
MyEl.observedAttribute = ['style']

customElements.define('my-el', MyEl)
```

All three methods works. The browser only needs to read the property, but it doesn't matter how it gets there in the first place.

Even this works:

```js

class MyEl extends HTMLElement { /* ... */ }

// This is even another way to define a "static" property on a class.
Object.defineProperty(MyEl, 'observedAttribute', {
  value: ['style'],
  writable: true,
  enumerable: true,
  configurable: true,
})

customElements.define('my-el', MyEl)
```

Eventually static class properties landed (for non-methods). So then it became simpler:


```js
class MyEl extends HTMLElement {
  static observedAttribute = ['style']
}

console.log(MyEl.observedAttributes) // ['style']

customElements.define('my-el', MyEl)
```

-- 
GitHub Notification of comment by trusktr
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/996#issuecomment-668993594 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 5 August 2020 05:47:30 UTC