Elment.attributes does not implement the NamedNodeMap interface
See original GitHub issueI was trying to replace JSDOM with Happy DOM and the app was failing to run something akin to:
const element = document.createElement('div');
const someAttribute = document.createAttribute('someattribute');
element.attributes.setNamedItem(someAttribute);
I see the current implementation is:
readonly attributes: { [k: string]: Attr | number };
Is there any chance there will be a switch to NamedNodeMap in the future?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:8 (3 by maintainers)
Top Results From Across the Web
NamedNodeMap - Web APIs | MDN
Chrome Edge
NamedNodeMap Full support. Chrome1. Toggle history Full support. Edge12. Toggle history
getNamedItem Full support. Chrome1. Toggle history Full support. Edge12. Toggle history
getNamedItemNS Full...
Read more >NamedNodeMap interface - PTC Support
Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not...
Read more >Retrieving map of attributes in DOM 4 - Stack Overflow
An Attribute of an Element . Attributes no longer implement the Node interface as of DOM4. Are they talking about Attr ? But...
Read more >Missing string indexer on NamedNodeMap interface in lib ...
I can't tell from the MDN docs for NamedNodeMap if it's standard or not. All they seem to mention is "Attr nodes' indexes...
Read more >Document Object Model (Core) Level 1 - W3C
In the DOM Level 1, objects implementing some interface "X" are created by a ... returned implements the Element interface, so attributes can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue seems to be the last one preventing a drop-in replacement from
jsdom
. I’m usingvitest
&@vue/test-utils@1
and I can’t switch because of the errorTypeError: attributes.item is not a function
which is thrown from within@vue/test-utils
and is unavoidable.Thank you contributing @jledentu! 🙂
There is a fix in now.
You can read more about the release here: https://github.com/capricorn86/happy-dom/releases/tag/v7.6.0