|
@ -50,14 +50,13 @@ class Element extends \DOMElement { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function setAttribute($name, $value) { |
|
|
public function setAttribute($name, $value) { |
|
|
try { |
|
|
|
|
|
// If setting a class attribute and classList has been invoked use classList to |
|
|
// If setting a class attribute and classList has been invoked use classList to |
|
|
// set it. |
|
|
// set it. |
|
|
if ($this->_classList !== null && $name === 'class') { |
|
|
if ($name === 'class' && $this->_classList !== null) { |
|
|
$this->_classList->value = $value; |
|
|
$this->_classList->value = $value; |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
try { |
|
|
parent::setAttribute($name, $value); |
|
|
parent::setAttribute($name, $value); |
|
|
} |
|
|
|
|
|
} catch (\DOMException $e) { |
|
|
} catch (\DOMException $e) { |
|
|
// The attribute name is invalid for XML |
|
|
// The attribute name is invalid for XML |
|
|
// Replace any offending characters with "UHHHHHH" where H are the |
|
|
// Replace any offending characters with "UHHHHHH" where H are the |
|
@ -70,32 +69,35 @@ class Element extends \DOMElement { |
|
|
$this->setIdAttribute($name, true); |
|
|
$this->setIdAttribute($name, true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function setAttributeNS($namespaceURI, $qualifiedName, $value) { |
|
|
public function setAttributeNS($namespaceURI, $qualifiedName, $value) { |
|
|
try { |
|
|
|
|
|
// If setting a class attribute and classList has been invoked use classList to |
|
|
// If setting a class attribute and classList has been invoked use classList to |
|
|
// set it. |
|
|
// set it. |
|
|
if ($this->_classList !== null && $namespaceURI === null && $qualifiedName === 'class') { |
|
|
if ($qualifiedName === 'class' && $namespaceURI === null && $this->_classList !== null) { |
|
|
$this->_classList->value = $value; |
|
|
$this->_classList->value = $value; |
|
|
} else { |
|
|
} else { |
|
|
parent::setAttributeNS($namespaceURI, $qualifiedName, $value); |
|
|
try { |
|
|
} |
|
|
// NOTE: We create attribute nodes so that xmlns attributes don't get lost |
|
|
|
|
|
$a = $this->ownerDocument->createAttributeNS($namespaceURI, $qualifiedName); |
|
|
} catch (\DOMException $e) { |
|
|
} catch (\DOMException $e) { |
|
|
// The attribute name is invalid for XML |
|
|
// The attribute name is invalid for XML |
|
|
// Replace any offending characters with "UHHHHHH" where H are the |
|
|
// Replace any offending characters with "UHHHHHH" where H are the |
|
|
// uppercase hexadecimal digits of the character's code point |
|
|
// uppercase hexadecimal digits of the character's code point |
|
|
$this->ownerDocument->mangledAttributes = true; |
|
|
$this->ownerDocument->mangledAttributes = true; |
|
|
$qualifiedName = $this->coerceName($qualifiedName); |
|
|
$qualifiedName = $this->coerceName($qualifiedName); |
|
|
parent::setAttributeNS($namespaceURI, $qualifiedName, $value); |
|
|
$a = $this->ownerDocument->createAttributeNS($namespaceURI, $qualifiedName); |
|
|
} |
|
|
} |
|
|
|
|
|
$a->value = $this->escapeString($value, true); |
|
|
|
|
|
$this->appendChild($a); |
|
|
if ($qualifiedName === "id" && $namespaceURI === null) { |
|
|
if ($qualifiedName === "id" && $namespaceURI === null) { |
|
|
$this->setIdAttribute($qualifiedName, true); |
|
|
$this->setIdAttribute($qualifiedName, true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function setAttributeNode(\DOMAttr $attribute) { |
|
|
public function setAttributeNode(\DOMAttr $attribute) { |
|
|
parent::setAttributeNode($attribute); |
|
|
parent::setAttributeNode($attribute); |
|
|
|
|
|
|
|
|
if ($attribute->name === 'id') { |
|
|
if ($attribute->name === 'id') { |
|
|
$this->setIdAttribute($attribute->name, true); |
|
|
$this->setIdAttribute($attribute->name, true); |
|
|
} |
|
|
} |
|
@ -103,8 +105,7 @@ class Element extends \DOMElement { |
|
|
|
|
|
|
|
|
public function setAttributeNodeNS(\DOMAttr $attribute) { |
|
|
public function setAttributeNodeNS(\DOMAttr $attribute) { |
|
|
parent::setAttributeNodeNS($attribute); |
|
|
parent::setAttributeNodeNS($attribute); |
|
|
|
|
|
if ($attribute->name === 'id' && $attribute->namespaceURI === null) { |
|
|
if ($attribute->name === 'id') { |
|
|
|
|
|
$this->setIdAttribute($attribute->name, true); |
|
|
$this->setIdAttribute($attribute->name, true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|