Package cssutils :: Package css :: Module cssstylerule :: Class CSSStyleRule
[hide private]
[frames] | no frames]

Class CSSStyleRule

source code

 object --+        
          |        
  util.Base --+    
              |    
cssrule.CSSRule --+
                  |
                 CSSStyleRule

The CSSStyleRule object represents a ruleset specified (if any) in a CSS style sheet. It provides access to a declaration block as well as to the associated group of selectors.

Properties

selectorList: of type SelectorList (cssutils only)
A list of all Selector elements for the rule set.
selectorText: of type DOMString
The textual representation of the selector for the rule set. The implementation may have stripped out insignificant whitespace while parsing the selector.
style: of type CSSStyleDeclaration, (DOM)
The declaration-block of this rule set.
type
the type of this rule, constant cssutils.CSSRule.STYLE_RULE
inherited properties:
  • cssText
  • parentRule
  • parentStyleSheet

Format

ruleset:

: selector [ COMMA S* selector ]*
LBRACE S* declaration [ ';' S* declaration ]* '}' S*
;
Nested Classes [hide private]

Inherited from util.Base (private): _prods

Instance Methods [hide private]
 
__init__(self, selectorText=None, style=None, parentRule=None, parentStyleSheet=None, readonly=False)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_getCssText(self)
returns serialized property cssText
source code
 
_setCssText(self, cssText)
DOMException on setting
source code
 
__getNamespaces(self)
uses children namespaces if not attached to a sheet, else the sheet's ones
source code
 
_setSelectorList(self, selectorList) source code
 
_setSelectorText(self, selectorText)
wrapper for cssutils SelectorList object
source code
 
_setStyle(self, style) source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code

Inherited from cssrule.CSSRule (private): _getTypeString

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]
  type = 1
The type of this rule, as defined by a CSSRule type constant.

Inherited from cssrule.CSSRule: CHARSET_RULE, COMMENT, FONT_FACE_RULE, IMPORT_RULE, MEDIA_RULE, NAMESPACE_RULE, PAGE_RULE, STYLE_RULE, UNKNOWN_RULE

Inherited from cssrule.CSSRule (private): _typestrings

Inherited from util.Base (private): _SHORTHANDPROPERTIES, _log

Properties [hide private]
  cssText
(DOM) The parsable textual representation of the rule.
  _namespaces
if this Rule is attached to a CSSStyleSheet the namespaces of that sheet are mirrored here.
  selectorList
The SelectorList of this rule.
  selectorText
(DOM) The textual representation of the selector for the rule set.
  style
(DOM) The declaration-block of this rule set.

Inherited from cssrule.CSSRule: parentRule, parentStyleSheet, typeString

Inherited from object: __class__

Method Details [hide private]

__init__(self, selectorText=None, style=None, parentRule=None, parentStyleSheet=None, readonly=False)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • selectorText - string parsed into selectorList
  • style - string parsed into CSSStyleDeclaration for this CSSStyleRule
  • readonly - if True allows setting of properties in constructor only
Overrides: object.__init__

_getCssText(self)

source code 
returns serialized property cssText
Overrides: cssrule.CSSRule._getCssText

_setCssText(self, cssText)

source code 

DOMException on setting

  • SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.

  • INVALID_MODIFICATION_ERR: Raised if the specified CSS string value represents a different type of rule than the current one.

  • HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at this point in the style sheet.

  • NO_MODIFICATION_ALLOWED_ERR: (self) Raised if the rule is readonly.

Parameters:
  • cssText - a parseable string or a tuple of (cssText, dict-of-namespaces)
Raises:
  • NAMESPACE_ERR - (Selector) Raised if the specified selector uses an unknown namespace prefix.
  • SYNTAX_ERR - (self, StyleDeclaration, etc) Raised if the specified CSS string value has a syntax error and is unparsable.
  • INVALID_MODIFICATION_ERR - (self) Raised if the specified CSS string value represents a different type of rule than the current one.
  • HIERARCHY_REQUEST_ERR - (CSSStylesheet) Raised if the rule cannot be inserted at this point in the style sheet.
  • NO_MODIFICATION_ALLOWED_ERR - (CSSRule) Raised if the rule is readonly.
Overrides: cssrule.CSSRule._setCssText

_setSelectorList(self, selectorList)

source code 
Parameters:
  • selectorList - selectorList, only content is used, not the actual object

_setSelectorText(self, selectorText)

source code 
wrapper for cssutils SelectorList object
Parameters:
  • selectorText - of type string, might also be a comma separated list of selectors
Raises:
  • NAMESPACE_ERR - (Selector) Raised if the specified selector uses an unknown namespace prefix.
  • SYNTAX_ERR - (SelectorList, Selector) Raised if the specified CSS string value has a syntax error and is unparsable.
  • NO_MODIFICATION_ALLOWED_ERR - (self) Raised if this rule is readonly.

_setStyle(self, style)

source code 
Parameters:
  • style - CSSStyleDeclaration or string, only the cssText of a declaration is used, not the actual object

__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]

cssText

(DOM) The parsable textual representation of the rule.
Get Method:
_getCssText(self) - returns serialized property cssText
Set Method:
_setCssText(self, cssText) - DOMException on setting

_namespaces

if this Rule is attached to a CSSStyleSheet the namespaces of that sheet are mirrored here. While the Rule is not attached the namespaces of selectorList are used.
Get Method:
__getNamespaces(self) - uses children namespaces if not attached to a sheet, else the sheet's ones

selectorList

The SelectorList of this rule.
Get Method:
unreachable(self)
Set Method:
_setSelectorList(self, selectorList)

selectorText

(DOM) The textual representation of the selector for the rule set.
Get Method:
unreachable(self)
Set Method:
_setSelectorText(self, selectorText) - wrapper for cssutils SelectorList object

style

(DOM) The declaration-block of this rule set.
Get Method:
unreachable(self)
Set Method:
_setStyle(self, style)