This chapter describes the optional CSS Object Model level 3 Editing
feature. Its CSSSelectorQuery interface
provide easy-to-use, robust, selective access to a set of the simple
selectors contained in all stylesheets attached to a document.
Note: CSS Object Model level 2 is Document Object Model level 2 CSS. There are no CSS Object Model levels 0 and 1.
The interfaces found within this section are not mandatory. A DOM
application may use the hasFeature(feature, version)
method of the DOMImplementation
interface with parameter
values "CSS Editing" and "3.0" (respectively) to determine whether or
not this module is supported by the implementation. In order to fully
support this module, an implementation must also support the "CSS"
feature defined defined in the DOM Level 2 CSS specification. Please
refer to additional information about conformance in the DOM
Level 2 CSS specification.
CSSSelectorQuery
allows the user to retrieve a list in
alphabetical order, returned in a DOMStringList
(introduced in DOM
Level 3 Core) object, of some simple
selectors used in a CSS
style rule, a CSS
style sheet or in all the stylesheets attached to a document.
The expectation is that an instance of the CSSSelectorQuery
interface can be obtained by using binding-specific casting methods on
an instance of the CSSStyleRule
,CSSStyleSheet
and Document
interfaces.
The getSelectorList
method provides a mechanism
through which a DOM author can immediately retrieve an alphabetically
ordered list of a the type selectors, class selectors and ID
selectors used in a style rule, a style sheet or all the
stylesheets attached to a given document.
// Introduced in CSS OM level 3 Editing:
interface CSSSelectorQuery {
// Constants for selector filters
const unsigned long SHOW_ALL = 0xFFFFFFFF;
const unsigned long SHOW_TYPE_SELECTOR = 0x00000001;
const unsigned long SHOW_CLASS_SELECTOR = 0x00000002;
const unsigned long SHOW_ID_SELECTOR = 0x00000004;
DOMStringList getSelectorList(in unsigned long selectorFilter);
};
These are the available values for the selectorFilter
parameter used in CSSSelectorQuery
. Their
values are derived by using a bit position. If a bit in
selectorFilter
is set false, that will be taken as a request to skip over this type
of simple selector during the traversal of all the simple selectors
used in the object, in order to fulfill the request.
SHOW_ALL
selectors and
ID
selectors used in the object.SHOW_TYPE_SELECTOR
SHOW_CLASS_SELECTOR
selectors used in the object,
ie strings consisting of a period followed by a class name.SHOW_ID_SELECTOR
getSelectorList
selectorFilter
of
type unsigned long
SHOW_
values.
These flags can be combined using OR
.
|
The alphabetically ordered list of all simple selectors matching the selector filter. |