diff --git a/lib/Node.php b/lib/Node.php index e704905..1b5f416 100644 --- a/lib/Node.php +++ b/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; } } diff --git a/tests/cases/TestNode.php b/tests/cases/TestNode.php index 7894852..01cc113 100644 --- a/tests/cases/TestNode.php +++ b/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')));