Skip to content

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

Closed

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

Activity

  1. self-assigned this
    on Dec 23, 2023
  2. added a commit that references this issue on Dec 24, 2023
    6378c84
  3. added a commit that references this issue on Dec 27, 2023
    93951cf
  4. added a commit that references this issue on Dec 27, 2023
    2e12e80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions