Skip to content

setAttributeNode and setAttributeNodeNS can be an aliases #117

Closed
@foolip

Description

@foolip

Another thing I found when investigating https://code.google.com/p/chromium/issues/detail?id=502301

In Blink/WebKit, setAttributeNode and setAttributeNodeNS are simply aliases. This means that there is no namespace and local name flag, and a case-insensitive search for an existing attribute is always done, for HTML documents. (Per spec it would be lowercasing attr.localName instead.)

An ad-hoc test, where Edge behaves like Blink/WebKit, while Gecko is the only engine to end up with two attributes:
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3761

What the spec says is probably web compatible, but with some strangeness:

  1. As of Make createAttribute() lowercase the input in HTML documents #75, createAttribute will lowercase the input, so also lowercasing attr.localName is unlikely to be needed for compat.
  2. By doing get an attribute by name and removing the found attribute, there can still be more attributes by the same name, so no interesting invariant is upheld: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3762

So what to do?

My proposal is to make setAttributeNode do the equivalent of getAttributeNodeNS(attr.namespaceURI, attr.localName) with no lowercasing or case-insensitive lookup. setAttributeNodeNS would be an exact alias, and we could consider removing it. Usage is super low.

CC @bzbarsky @Ms2ger

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions