Re: [csswg-drafts] [cssom][css-syntax] Initial filling the CSS rules of a CSS style sheet or a grouping rule

Hmm, looks like I have not descibed my problem clearly.

Let's start with CSS content e.g. from a fetched resource (external stylesheet) or an HTML `style` element's content. Now we want to create a CSSOM `CSSStyleSheet` object representing the CSS content. So we create a CSSOM `CSSStyleSheet` object with an empty list of `CSSRule`s. Now our CSS content contains several rules. So we want the list of rules of our `CSSStyleSheet` object to contain several `CSSRule` objects. Somehow we want to create `CSSRule` objects and **initially** insert them into this list. But neither the `CSSStyleSheet` nor the `CSSRuleList` has a procedure for setting potentially **several** CSS rules from **one** string.  There _is_ a procedure to 'parse a CSS rule' from a string, but it applies to a string containing **one** rule. So how do we know where one rule ends and another starts? 

We can use a parser implementing the procedures defined in css-syntax to 'parse a stylesheet'. This creates a stylesheet (not CSSOM `CSSStyleSheet`) with a list of rules (at-rule or qualified rule; not CSSOM `CSSRule`) as its value. But we're not content yet, because we want to have CSSOM `CSSRule` objects.

Now: how do we get there? How do we a) create a CSSOM `CSSRule` object from css-syntax rule in order to b) populate the initially empty list of `CSSRule` objects of the newly created `CSSStyleSheet` object?

The procedures suggested in my second comment could describe this job.

-- 
GitHub Notification of comment by waldbaerkoch
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1754#issuecomment-326421422 using your GitHub account

Received on Thursday, 31 August 2017 21:09:47 UTC