W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2006

property for selector text specificity [CSSStyleRule ]

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Thu, 16 Feb 2006 13:44:12 -0500
Message-ID: <c9e12660602161044r50ac8714gae7288705b830b11@mail.gmail.com>
To: DOM mailing list <www-dom@w3.org>

This is about reading a cssRule's selector text specificity.


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.

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

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:13 UTC