question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Elment.attributes does not implement the NamedNodeMap interface

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
matt-smarshcommented, Sep 9, 2022

This issue seems to be the last one preventing a drop-in replacement from jsdom. I’m using vitest & @vue/test-utils@1 and I can’t switch because of the error TypeError: attributes.item is not a function which is thrown from within @vue/test-utils and is unavoidable.

3reactions
capricorn86commented, Oct 18, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found