Browse Source

Fixes to attributes in Node::isEqualNode

master
Dustin Wilson 2 years ago
parent
commit
5311f14e5b
  1. 8
      lib/Node.php
  2. 5
      tests/cases/TestNode.php

8
lib/Node.php

@ -1061,8 +1061,12 @@ abstract class Node implements \Stringable {
# • If A is an element, each attribute in its attribute list has an attribute that
# equals an attribute in B’s attribute list.
$thisNodeAttributes = $thisNode->attributes;
foreach ($thisNodeAttributes as $key => $attr) {
if (!$this->isEqualInnerNode($attr, $otherAttributes[$key])) {
foreach ($thisNodeAttributes as $attr) {
if (!($otherAttr = $otherNode->getAttributeNodeNS($attr->namespaceURI, $attr->name))) {
return false;
}
if (!$this->isEqualInnerNode($attr, $otherAttr)) {
return false;
}
}

5
tests/cases/TestNode.php

@ -378,6 +378,11 @@ class TestNode extends \PHPUnit\Framework\TestCase {
$this->assertFalse($html->isEqualNode($html2));
$html->appendChild($body);
$this->assertFalse($html->isEqualNode($html2));
$html = $d->createElement('html');
$html->setAttribute('id', 'ook');
$html2 = $d->createElement('html');
$html2->setAttribute('class', 'ook');
$this->assertFalse($html->isEqualNode($html2));
// Different text nodes
$this->assertFalse($d->createTextNode('ook')->isEqualNode($d->createTextNode('eek')));

Loading…
Cancel
Save