|
@ -15,10 +15,15 @@ class Element extends \DOMElement { |
|
|
// Newer versions of the DOM spec have getAttribute return an empty string only |
|
|
// Newer versions of the DOM spec have getAttribute return an empty string only |
|
|
// when the attribute exists and is empty, otherwise null. This fixes that. |
|
|
// when the attribute exists and is empty, otherwise null. This fixes that. |
|
|
$value = parent::getAttribute($name); |
|
|
$value = parent::getAttribute($name); |
|
|
if ($value === '' && !$this->hasAttribute($name)) { |
|
|
if ($value === '' && !parent::hasAttribute($name)) { |
|
|
|
|
|
// the PHP DOM does not acknowledge the presence of XMLNS-namespace attributes |
|
|
|
|
|
foreach ($this->attributes as $a) { |
|
|
|
|
|
if ($a->nodeName === $name) { |
|
|
|
|
|
return $a->value; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $value; |
|
|
return $value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -29,7 +34,6 @@ class Element extends \DOMElement { |
|
|
if ($value === '' && !$this->hasAttributeNS($namespaceURI, $localName)) { |
|
|
if ($value === '' && !$this->hasAttributeNS($namespaceURI, $localName)) { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $value; |
|
|
return $value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -131,13 +135,10 @@ class Element extends \DOMElement { |
|
|
return $this->getAttributeNode('class'); |
|
|
return $this->getAttributeNode('class'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$result = parent::setAttributeNodeNS($attribute); |
|
|
$result = parent::setAttributeNodeNS($attribute); |
|
|
|
|
|
|
|
|
if ($fixId) { |
|
|
if ($fixId) { |
|
|
$this->setIdAttribute($attribute->name, true); |
|
|
$this->setIdAttribute($attribute->name, true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $result; |
|
|
return $result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -151,12 +152,9 @@ class Element extends \DOMElement { |
|
|
if ($this->_classList === null) { |
|
|
if ($this->_classList === null) { |
|
|
$this->_classList = new TokenList($this, 'class'); |
|
|
$this->_classList = new TokenList($this, 'class'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->_classList; |
|
|
return $this->_classList; |
|
|
} |
|
|
} |
|
|
|
|
|
return null; // @codeCoverageIgnore |
|
|
return null; |
|
|
|
|
|
break; |
|
|
|
|
|
### DOM Parsing Specification ### |
|
|
### DOM Parsing Specification ### |
|
|
# 2.3 The InnerHTML mixin |
|
|
# 2.3 The InnerHTML mixin |
|
|
# |
|
|
# |
|
@ -165,8 +163,8 @@ class Element extends \DOMElement { |
|
|
# might throw an exception instead of returning a string). |
|
|
# might throw an exception instead of returning a string). |
|
|
// DEVIATION: Parsing of XML documents will not be handled by this |
|
|
// DEVIATION: Parsing of XML documents will not be handled by this |
|
|
// implementation, so there's no need for the well-formed flag. |
|
|
// implementation, so there's no need for the well-formed flag. |
|
|
case 'innerHTML': return $this->serialize($this); |
|
|
case 'innerHTML': |
|
|
break; |
|
|
return $this->serialize($this); |
|
|
### DOM Parsing Specification ### |
|
|
### DOM Parsing Specification ### |
|
|
# 2.4 Extensions to the Element interface |
|
|
# 2.4 Extensions to the Element interface |
|
|
# outerHTML |
|
|
# outerHTML |
|
@ -180,8 +178,10 @@ class Element extends \DOMElement { |
|
|
// OPTIMIZATION: When following the instructions above the fragment serializing |
|
|
// OPTIMIZATION: When following the instructions above the fragment serializing |
|
|
// algorithm (Element::serialize) would invoke Element::__toString, so just |
|
|
// algorithm (Element::serialize) would invoke Element::__toString, so just |
|
|
// doing that instead of multiple function calls. |
|
|
// doing that instead of multiple function calls. |
|
|
case 'outerHTML': return $this->__toString(); |
|
|
case 'outerHTML': |
|
|
break; |
|
|
return $this->__toString(); |
|
|
|
|
|
default: |
|
|
|
|
|
return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|