Re: [w3c/webcomponents] Provide a lightweight mechanism to add styles to a custom element (#468)

So in my understanding

```js
class MyElement extends HTMLElement {
  constructor() {
    super();
  }
}

// if constructable stylesheet is a thing
var css = new CSSStyleSheet(':host { color: blue; }');  

customElements.define('my-element', MyElement);
var my_element = document.createElement('my-element', css);
document.body.appendChild(my_element);
```
Then `color: blue` is applied to every `<my-element>`, although at this moment you have no way to retrieve the `CSSStyleSheet` object from the element itself.

and then,
```js
var root = my_element.appendShadow({mode: 'open'});
```
will make it appear in `root.styleSheets(0)`, such that
```js
root.styleSheets(0) === css
```
is true.

-- 
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/468#issuecomment-371372008

Received on Thursday, 8 March 2018 04:04:42 UTC