示例#1
0
 def _set_data(self, data):
     if not IsDOMString(data):
         raise SyntaxErr()
     old_value = self.__dict__['__nodeValue']
     self.__dict__['__nodeValue'] = data
     self._length = len(data)
     self._4dom_fireMutationEvent('DOMCharacterDataModified',
                                  prevValue=old_value,
                                  newValue=data)
示例#2
0
 def replaceData(self, offset, count, arg):
     if not IsDOMString(arg):
         raise SyntaxErr()
     if count < 0 or offset < 0 or offset > self._length:
         raise IndexSizeErr()
     data = self.__dict__['__nodeValue']
     data = data[:int(offset)] + arg + data[int(offset + count):]
     self._set_data(data)
     self._4dom_fireMutationEvent('DOMSubtreeModified')
     return
示例#3
0
 def setAttribute(self, name, value):
     if not IsDOMString(value):
         raise SyntaxErr()
     if not g_namePattern.match(name):
         raise InvalidCharacterErr()
     attr = self.attributes.getNamedItem(name)
     if attr:
         attr.value = value
     else:
         attr = self.ownerDocument.createAttribute(name)
         attr.value = value
         self.setAttributeNode(attr)
示例#4
0
    def setAttributeNS(self, namespaceURI, qualifiedName, value):
        if not IsDOMString(value):
            raise SyntaxErr()
        if not g_namePattern.match(qualifiedName):
            raise InvalidCharacterErr()

        prefix, localName = SplitQName(qualifiedName)
        attr = self.attributes.getNamedItemNS(namespaceURI, localName)
        if attr:
            attr.value = value
        else:
            attr = self.ownerDocument.createAttributeNS(namespaceURI, qualifiedName)
            attr.value = value
            self.setAttributeNodeNS(attr)
        return