Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix @skatejs/ssr in jsdom environment #1575

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NMinhNguyen
Copy link
Member

@NMinhNguyen NMinhNguyen commented Feb 21, 2020

NodeLists don't have a map method.
See https://developer.mozilla.org/en-US/docs/Web/API/NodeList

If there is a linked issue, mention it here.

  • Bug
  • Feature

Requirements

Rationale

Why is this PR necessary?

NodeLists don't have a map method.
See https://developer.mozilla.org/en-US/docs/Web/API/NodeList

I have existing tests using undom but I've had a lot of luck switching over to https://github.com/SimenB/jest-environment-jsdom-sixteen (see https://github.com/jsdom/jsdom/releases/tag/16.2.0).

Implementation

Why have you implemented it this way? Did you try any other methods?

I considered using Array spread or Array.from but went with this approach to avoid creating arrays. Happy to change the implementation for terseness though.

Open questions

Are there any open questions about this implementation that need answers?

Other

Is there anything else we should know? Delete this section if you don't need it.

I've tested both this approach (as well as using Array spread) in my project via https://github.com/ds300/patch-package and everything works.

@vercel
Copy link

vercel bot commented Feb 21, 2020

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

@@ -17,22 +17,24 @@ function stringify(node) {
return node.textContent;
}

str += `<${node.localName}${(node.attributes || [])
.map(a => ` ${a.name}="${a.value}"`)
const { map } = Array.prototype;
Copy link
Member

Choose a reason for hiding this comment

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

Should probably hoist this out of the function scope.

@treshugart
Copy link
Member

Left one small nit but otherwise lgtm.

@treshugart
Copy link
Member

Discussed in Twitter DM, but we'll just keep the map destructure inline for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants