Re: [w3ctag/design-reviews] Constructable Stylesheets (#308)

The new methods PR had been merged and the explainer has been updated.  The explainer isn't currently addressing your points though. I think for your first point something like this might make sense:

```js
const myElementSheet = new CSSStyleSheet();
class MyElement extends HTMLElement {
  constructor() {
    super();
    const shadowRoot = this.attachShadow({mode: "open"});
    shadowRoot.adoptedStyleSheets = [myElementSheet];
  }
  
  connectedCallback() {
    // Only actually parse the stylesheet when the first instance is connected.
    if (myElementSheet.cssRules.length == 0) {
       myElementSheet.replaceSync(styleText);
    }
  }
}
```

Looks reasonable to me but I might be wrong.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/308#issuecomment-446180983

Received on Tuesday, 11 December 2018 12:11:40 UTC