Skip to content

Adding NamedNodeMap to global export #85

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

Conversation

mikemadest
Copy link
Contributor

@mikemadest mikemadest commented Jul 19, 2021

The reason for this PR is this error when running Axe tests in a React app,
using Jest with a linkedom environment:

image

And this is the axe test involved:

    function getNodeAttributes(node) {
      if (node.attributes instanceof window.NamedNodeMap) {
        return node.attributes;
      }
      return node.cloneNode(false).attributes;
    }

What happen is that NamedNodeMap, despite being in linkedom interface, wasn't available in window, which is what this PR intend to change.

Mickael Meausoone added 2 commits July 19, 2021 09:21
that object is expected to be in the global context when running jest test (for Axe checks)

let node = document.documentElement.firstElementChild;

assert(typeof NamedNodeMap !== 'undefined', true, 'NamedNodeMap undefined in global export');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention was to add a unit test related to the change here. I couldn't find similar checks for other exported objects but felt bad not adding something...

@@ -30,6 +30,7 @@ import {InputEvent} from './input-event.js';
import {ImageClass} from './image.js';
import {MutationObserverClass} from './mutation-observer.js';
import {NodeList} from './node-list.js';
import {NamedNodeMap} from './named-node-map.js';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind moving this above the previous line? Just to preserve the alphabetical order, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, thanks for your feedback 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@WebReflection
Copy link
Owner

Thanks, beside one line to move, this looks good to me 👍

@WebReflection WebReflection merged commit 36a2b27 into WebReflection:main Jul 19, 2021
@mikemadest mikemadest deleted the global-export-named-node-map branch July 19, 2021 12:21
mikemadest added a commit to mikemadest/linkedom that referenced this pull request Jul 21, 2021
* Adding NamedNodeMap to global export
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants