property for selector text specificity [CSSStyleRule ]

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).

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.

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.

Sorting CSS rules by selector-text specificity is necessary for
stylesheet editors.
This functionality can be easily exposed by the browser.


--
http://dhtmlkitchen.com/

Received on Thursday, 16 February 2006 18:44:21 UTC