Package cssutils :: Package css :: Module selector :: Class Selector |
[hide private]
[frames] | no frames]

# Class Selector

source code

    object --+
             |
     util.Base --+
                 |
        util.Base2 --+
                     |
                    Selector

(cssutils) a single selector in a SelectorList of a CSSStyleRule

# Properties

selectorText
  textual representation of this Selector
namespaces
  TODO: a dict of {prefix: namespaceURI} mapping, may also be a CSSStyleSheet in which case the namespaces defined there are used. If None cssutils tries to get the namespaces as defined in a possible parent CSSStyleSheet.
parentRule: of type CSSRule, readonly
  The CSS rule that contains this declaration block or None if this CSSStyleDeclaration is not attached to a CSSRule.
prefixes
  a set which prefixes have been used in this selector
seq
  sequence of Selector parts including comments
specificity (READONLY)

  tuple of (a, b, c, d) where:

  a
    presence of style in document, currently always 0
  b
    # of ID selectors
  c
    # of .class selectors
  d
    # of Element (type) selectors
wellformed
  if this selector is wellformed regarding the Selector spec

# Format

    # implemented in SelectorList
    selectors_group
      : selector [ COMMA S* selector ]*
      ;

    selector
      : simple_selector_sequence [ combinator simple_selector_sequence ]*
      ;

    combinator
      /* combinators can be surrounded by white space */
      : PLUS S* | GREATER S* | TILDE S* | S+
      ;

    simple_selector_sequence
      : [ type_selector | universal ]
        [ HASH | class | attrib | pseudo | negation ]*
      | [ HASH | class | attrib | pseudo | negation ]+
      ;

    type_selector
      : [ namespace_prefix ]? element_name
      ;

    namespace_prefix
      : [ IDENT | '*' ]? '|'
      ;

    element_name
      : IDENT
      ;

    universal
      : [ namespace_prefix ]? '*'
      ;

    class
      : '.' IDENT
      ;

    attrib
      : '[' S* [ namespace_prefix ]? IDENT S*
            [ [ PREFIXMATCH |
                SUFFIXMATCH |
                SUBSTRINGMATCH |
                '=' |
                INCLUDES |
                DASHMATCH ] S* [ IDENT | STRING ] S*
            ]? ']'
      ;

    pseudo
      /* '::' starts a pseudo-element, ':' a pseudo-class */
      /* Exceptions: :first-line, :first-letter, :before and :after. */
      /* Note that pseudo-elements are restricted to one per selector and */
      /* occur only in the last simple_selector_sequence. */
      : ':' ':'? [ IDENT | functional_pseudo ]
      ;

    functional_pseudo
      : FUNCTION S* expression ')'
      ;

    expression
      /* In CSS3, the expressions are identifiers, strings, */
      /* or of the form "an+b" */
      : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
      ;

    negation
      : NOT S* negation_arg S* ')'
      ;

    negation_arg
      : type_selector | universal | HASH | class | attrib | pseudo
      ;

Nested Classes | [hide private]
Inherited from `util.Base` (private): `_prods`

Instance Methods | [hide private]
__init__(self, selectorText=None, namespaces=None, parentRule=None, readonly=False) initial value of this selector | source code
_getParentRule(self) | source code
_setParentRule(self, parentRule) | source code
_getSelectorText(self) returns serialized format | source code
_setSelectorText(self, selectorText) sets this selectorText | source code
__repr__(self) repr(x) | source code
__str__(self) str(x) | source code
Inherited from `util.Base2` (private): `_setSeq`, `_tempSeq` Inherited from `util.Base` (private): `_checkReadonly`, `_nexttoken`, `_parse`, `_tokenize2`, `_tokensupto2`, `_tokenvalue`, `_type`, `_valuestr` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`

Static Methods | [hide private]
Inherited from `util.Base` (private): `_normalize`

Class Variables | [hide private]
Inherited from `util.Base` (private): `_SHORTHANDPROPERTIES`, `_log`

Properties | [hide private]
| element Element of this selector (READONLY).
| parentRule (DOM) The CSS rule that contains this Selector or None if this Selector is not attached to a CSSRule.
| selectorText (DOM) The parsable textual representation of the selector.
| specificity specificity of this selector (READONLY).
Inherited from `util.Base2`: `seq` Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, selectorText=None, namespaces=None, parentRule=None, readonly=False) (Constructor) | source code
selectorText initial value of this selector parentRule a CSSStyleRule readonly default to False Overrides: util.Base2.__init__

### _setSelectorText(self, selectorText) | source code
sets this selectorText TODO: raises xml.dom.Exception

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

Property Details | [hide private]

  ### element Element of this selector (READONLY). Get Method: unreachable(self) Set Method:
      None
  Delete Method:
      None

  ### parentRule (DOM) The CSS rule that contains this Selector or None if this Selector is not attached to a CSSRule. Get Method: cssutils.css.selector.Selector._getParentRule(self) Set Method: cssutils.css.selector.Selector._setParentRule(self, parentRule) Delete Method:
      None

  ### selectorText (DOM) The parsable textual representation of the selector. Get Method: cssutils.css.selector.Selector._getSelectorText(self) - returns serialized format Set Method: cssutils.css.selector.Selector._setSelectorText(self, selectorText) - sets this selectorText Delete Method:
      None

  ### specificity specificity of this selector (READONLY). Get Method: unreachable(self) Set Method:
      None
  Delete Method:
      None