Skip to content

DOMNode::isEqualNode() is incorrect when attribute order is different #13012

Closed
@JoshyPHP

Description

@JoshyPHP

Description

The spec says: "If A is an element, each attribute in its attribute list has an attribute that equals an attribute in B’s attribute list." The order in which the attributes are listed should not matter.

I double checked the expected behaviour in Gecko/Blink just in case.

<?php

$dom = new DOMDocument;

// <x a="a" b="b"/>
$el1 = $dom->createElement('x');
$el1->setAttribute('a', 'a');
$el1->setAttribute('b', 'b');

// <x b="b" a="a"/>
$el2 = $dom->createElement('x');
$el2->setAttribute('b', 'b');
$el2->setAttribute('a', 'a');

var_dump($el1->isEqualNode($el2));

Resulted in this output:

bool(false)

But I expected this output instead:

bool(true)

PHP Version

PHP 8.3.1

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions