- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Mon, 11 Apr 2011 14:44:36 -0700
- To: "Tab Atkins Jr." <jackalmage@gmail.com>
- CC: www-style list <www-style@w3.org>
On 4/11/11 12:57 PM, Tab Atkins Jr. wrote: > Possible Solution: Add elem.rules(), which returns a list of rulesets > (CSSStyleRule) that apply to the element, ordered by decreasing > specificity. Gecko sort of has this internally. Webkit exposes this to web content, sort of. See the discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=438278 There are a bunch of open questions involving user/ua sheets, cross-site stylesheets, etc that need to be answered before exposing this sort of thing to web content. > Also, elem.rules(‘property’), which filters the rulesets > to only include ones which actually set the particular property. Note that this is not as useful as it may seem (e.g. elem.rules("color") has a good chance of not telling you anything useful). It's not clear to me whether the usefulness outweighs the footgun potential. > Possible Solution: Add an @id name; rule that can be added to > declaration blocks, and a document.ruleByID(name) function which > returns the ruleset with the given id. Or rather a ruleset with the given id; presumably one that comes last in cascade order? Again, the question of what to do for cross-site stylesheets remains. > Possible Solution: Add a rule.disable() and rule.enable() to CSSRule, > and rule.disable(‘property’) and rule.enable(‘property’) to > CSSStyleRule, which “turn off” the ruleset or the specific property, > and turn it back on again. This could possibly be reflected by a > !disabled value appended to the property. This makes sense to me for rules. I'm not sure about doing it on a per-property basis... > Possible Solution: Allow declaration blocks to be selected with > Selectors. A stylesheet is a root node, rulesets are children (some > types of rulesets, like media rules, can have more rulesets as > children), and properties are attributes on the ruleset. You could > then easily find your custom property by doing something like: This involves the parser doing "something" with properties it can't parse, right? I'm somewhat opposed to this. If you can't parse it, you have no idea how to expose it properly. I do note you considered this. > After all, the parser knows what the property's name was That's not necessarily true, no. > the error-handling implicitly looks for things that look like property > names and values so it can skip over them properly. No, the error-handling just looks for ';' not inside parens/brackets/quotes/etc. It's pretty easy to create things that look nothing like allowed property/value pairs and that current CSS parsers skip over just fine; you'd need to define new CSS parsing rules to make this work at all. -Boris
Received on Monday, 11 April 2011 21:45:11 UTC