fix: getAttribute and getAttributeNS should return null#477
Conversation
base on https://dom.spec.whatwg.org/#dom-element-getattribute, getAttribute() and related methods should return null for not existing attributes. speediness plea.
|
Thank you for the contribution. |
yes, you're right, I'll try |
karfau
left a comment
There was a problem hiding this comment.
I will have a closer look at the implementation of the related API like set and remove, to see if they are aligned with the spec, to make sure my suggested simplification doesn't break anything.
|
I had a look at it and fond some more issues, but those will be covered in a follow up PR by me, after which I will create the next beta release. Thank you for your contribution. |
getAttribute and getAttributeNS should return null
…xmldom#477)" This reverts commit 24108d4.
|
My great pleasure. |
…xmldom#477)" This reverts commit 24108d4.
- proper order in finding attributes (only affects duplicate attributes, which can only be created manually and anyways produce invalid XML) - properly remove item from previous last index (was not iterated over but the reference was kept) - set `ownerElement` to `null` even when `ownerElement.ownerDocument` is not set (which is an edge case which doesn't happen when parsing XML) - throw `DOMException` when there is no matching attribute - add test coverage - add doc comments regarding differences to the specification that still exist: - no named property indices support - add validation of qualified names in `Element` API which can throw `DOMException` as declared in the specs - always initialize required properties with `null` in `Attr` constructor BREAKING CHANGES: Mainly not throwing when removing an attribute that doesn't exist and other behavior that was different from the specification. closes #46 see #477
BREAKING CHANGE:
Element.getAttributeandElement.getAttributeNSreturnnullif the attribute doesn't existcloses #46
https://dom.spec.whatwg.org/#dom-element-getattribute