Garrett Smith wrote: > This is about reading a cssRule's selector text specificity. > > http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleRule > > var rule = document.styleSheets[0].cssRules[0]; > > // we get this one for free. > alert(rule.selectorText); // "p.aqua.marine" > > // we can't get this one for free, but we should. > alert(rule.specificity); // "33" (from 0x21). OK. What if rule.selectorText is "p.aqua.marine, div". What should rule.specificity be? "33"? Or "1"? Or "33, 1"? Or an array? > Dean Edwards' CssQuery parses out selector text using RegExp's. This > hard work is already done by the browser in applying rules. It could > easily be exposed so we would have it for free. I agree that this information should be exposed, yeah. I'm just not sure what a decent way to do it is. > The reason this is necessary is for stylesheet editors. A stylesheet > editor should sort the CSS Rules by their specificit so that the end > user can edit the most specific rule to the selected element. That approach really does not work for rules that have multiple selectors and a single declaration, unless your editor splits them up into multiple rules. -BorisReceived on Thursday, 16 February 2006 18:55:38 GMT
This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:43 GMT