cssText = property(_getCssText, _setCssText, doc = '(DOM) A parsable textual representation of the declaration block excluding the surrounding curly braces.')
parentRule = property((lambda self: self._parentRule), _setParentRule, doc = '(DOM) The CSS rule that contains this declaration block or None if this CSSStyleDeclaration is not attached to a CSSRule.')
def getProperties(self, name = None, all = False):
if name and not all:
p = self.getProperty(name)
if p:
return [
p]
return []
not all
if not all:
return [ self.getProperty(name) for name in self._CSSStyleDeclaration__nnames() ]
nname = self._normalize(name)
properties = []
for item in self.seq:
val = item.value
if isinstance(val, Property):
if bool(nname) == False or val.name == nname:
properties.append(val)
continue
all
return properties
def getProperty(self, name, normalize = True):
nname = self._normalize(name)
found = None
for item in reversed(self.seq):
val = item.value
if isinstance(val, Property):
if normalize or nname == val.name or name == val.literalname:
properties = self.getProperties(name, all = not normalize)
for property in reversed(properties):
if normalize and property.name == nname:
property.cssValue = newp.cssValue.cssText
property.priority = newp.priority
break
continue
if property.literalname == name:
property.cssValue = newp.cssValue.cssText
property.priority = newp.priority
break
continue
else:
newp.parent = self
self.seq._readonly = False
self.seq._readonly = True
def item(self, index):
names = list(self._CSSStyleDeclaration__nnames())
try:
return names[index]
except IndexError:
return u''
length = property((lambda self: len(list(self._CSSStyleDeclaration__nnames()))), doc = '(DOM) The number of distinct properties that have been explicitly in this declaration block. The range of valid indices is 0 to length-1 inclusive. These are properties with a different ``name`` only. :meth:`item` and :attr:`length` work on the same set here.')