CSS Object Model level 3 Editing

Author
Daniel Glazman <daniel@glazman.org>
Date
31-july-2003
Version
0.1

Table of contents

1.1. Overview

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.

1.1.1. CSSSelectorQuery

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.

1.2. Formal Interface Definition

InterfaceCSSSelectorQuery (introduced in CSS Object Model level 3 Editing)

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.

IDL Definition
// 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);

};
Definition group Constants for selector filters

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.

Defined Constants
SHOW_ALL
The resulting list will contain the textual representation of all type selectors, class selectors and ID selectors used in the object.
SHOW_TYPE_SELECTOR
The resulting list will contain the textual representation of all type selectors used in the object, ie strings consisting of elements names possibly preceeded by a namespace identifier and a vertical bar. Warning: type selectors should appear in the resulting list exactly as they appear in the stylesheets and no rewriting or canonicalization should be performed.
SHOW_CLASS_SELECTOR
The resulting list will contain the textual representation of all class selectors used in the object, ie strings consisting of a period followed by a class name.
SHOW_ID_SELECTOR
The resulting list will contain the textual representation of all ID selectors used in the object, ie strings consisting of a hash followed by an ID.
Methods
getSelectorList
Returns an alphabetically ordered list of the simple selectors used in the object according to the filter passed as a parameter.
Parameters
selectorFilter of type unsigned long
This flag specifies which simple selectors' textual representation may appear in the return value of the method. See the description of the Constants for selector filters definition group for the set of possible SHOW_ values. These flags can be combined using OR.
Return Value

DOMStringList

The alphabetically ordered list of all simple selectors matching the selector filter.

No Exceptions