-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: NodeList is not defined on window (#272)
- Loading branch information
Showing
6 changed files
with
289 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ node_modules/ | |
/utils/ | ||
/index.cjs | ||
/index.mjs | ||
/index.d.ts | ||
/index.d.ts | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="description" content="Partytown Test Page" /> | ||
<title>NodeList</title> | ||
<style> | ||
body { | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, | ||
Apple Color Emoji, Segoe UI Emoji; | ||
font-size: 12px; | ||
} | ||
h1 { | ||
margin: 0 0 15px 0; | ||
} | ||
ul { | ||
list-style-type: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
a { | ||
display: block; | ||
padding: 16px 8px; | ||
} | ||
a:link, | ||
a:visited { | ||
text-decoration: none; | ||
color: blue; | ||
} | ||
a:hover { | ||
background-color: #eee; | ||
} | ||
li { | ||
display: flex; | ||
margin: 15px 0; | ||
} | ||
li strong, | ||
li code, | ||
li button { | ||
white-space: nowrap; | ||
flex: 1; | ||
margin: 0 5px; | ||
} | ||
</style> | ||
<script> | ||
partytown = { | ||
logCalls: true, | ||
logGetters: true, | ||
logSetters: true, | ||
logStackTraces: false, | ||
logScriptExecution: true, | ||
logMainAccess: true, | ||
}; | ||
</script> | ||
<script src="/~partytown/debug/partytown.js"></script> | ||
</head> | ||
<body> | ||
<h1>NodeList</h1> | ||
<ul> | ||
<li> | ||
<strong>NodeList is defined</strong> | ||
<code id="testNodeList"></code> | ||
<script type="text/partytown"> | ||
(function () { | ||
const parentNode = document.createElement('div'); | ||
const childNodeOne = document.createElement('p'); | ||
const childNodeTwo = document.createElement('a'); | ||
const childNodeThree = document.createElement('span'); | ||
parentNode.appendChild(childNodeOne); | ||
parentNode.appendChild(childNodeTwo); | ||
parentNode.appendChild(childNodeThree); | ||
const nodeList = parentNode.childNodes; | ||
|
||
const isNodeListDefined = Boolean(NodeList && nodeList instanceof NodeList); | ||
|
||
document.getElementById('testNodeList').textContent += String(isNodeListDefined); | ||
})(); | ||
</script> | ||
</li> | ||
|
||
<li> | ||
<strong>entries()</strong> | ||
<code id="testNodeListEntries"></code> | ||
<script type="text/partytown"> | ||
(function () { | ||
const parentNode = document.createElement('div'); | ||
const childNodeOne = document.createElement('p'); | ||
const childNodeTwo = document.createElement('a'); | ||
const childNodeThree = document.createElement('span'); | ||
parentNode.appendChild(childNodeOne); | ||
parentNode.appendChild(childNodeTwo); | ||
parentNode.appendChild(childNodeThree); | ||
const nodeList = parentNode.childNodes; | ||
|
||
for (const [index, node] of nodeList.entries()) { | ||
document.getElementById('testNodeListEntries').textContent += | ||
index + ' ' + node.nodeName + ' '; | ||
} | ||
})(); | ||
</script> | ||
</li> | ||
|
||
<li> | ||
<strong>forEach()</strong> | ||
<code id="testNodeListForEach"></code> | ||
<script type="text/partytown"> | ||
(function () { | ||
const parentNode = document.createElement('div'); | ||
const childNodeOne = document.createElement('p'); | ||
const childNodeTwo = document.createElement('a'); | ||
const childNodeThree = document.createElement('span'); | ||
parentNode.appendChild(childNodeOne); | ||
parentNode.appendChild(childNodeTwo); | ||
parentNode.appendChild(childNodeThree); | ||
const nodeList = parentNode.childNodes; | ||
|
||
nodeList.forEach((childNode) => { | ||
document.getElementById('testNodeListForEach').textContent += | ||
childNode.nodeName + ' '; | ||
}); | ||
})(); | ||
</script> | ||
</li> | ||
|
||
<li> | ||
<strong>item()</strong> | ||
<code id="testNodeListItem"></code> | ||
<script type="text/partytown"> | ||
(function () { | ||
const parentNode = document.createElement('div'); | ||
const childNodeOne = document.createElement('p'); | ||
const childNodeTwo = document.createElement('a'); | ||
const childNodeThree = document.createElement('span'); | ||
parentNode.appendChild(childNodeOne); | ||
parentNode.appendChild(childNodeTwo); | ||
parentNode.appendChild(childNodeThree); | ||
const nodeList = parentNode.childNodes; | ||
|
||
document.getElementById('testNodeListItem').textContent += | ||
nodeList.item(0).nodeName + ' '; | ||
document.getElementById('testNodeListItem').textContent += | ||
nodeList.item(1).nodeName + ' '; | ||
document.getElementById('testNodeListItem').textContent += nodeList.item(2).nodeName; | ||
})(); | ||
</script> | ||
</li> | ||
|
||
<li> | ||
<strong>keys()</strong> | ||
<code id="testNodeListKeys"></code> | ||
<script type="text/partytown"> | ||
(function () { | ||
const parentNode = document.createElement('div'); | ||
const childNodeOne = document.createElement('p'); | ||
const childNodeTwo = document.createElement('a'); | ||
const childNodeThree = document.createElement('span'); | ||
parentNode.appendChild(childNodeOne); | ||
parentNode.appendChild(childNodeTwo); | ||
parentNode.appendChild(childNodeThree); | ||
const nodeList = parentNode.childNodes; | ||
|
||
for (const key of nodeList.keys()) { | ||
document.getElementById('testNodeListKeys').textContent += key + ' '; | ||
} | ||
})(); | ||
</script> | ||
</li> | ||
|
||
<li> | ||
<strong>length</strong> | ||
<code id="testNodeListLength"></code> | ||
<script type="text/partytown"> | ||
(function () { | ||
const parentNode = document.createElement('div'); | ||
const childNodeOne = document.createElement('p'); | ||
const childNodeTwo = document.createElement('a'); | ||
const childNodeThree = document.createElement('span'); | ||
parentNode.appendChild(childNodeOne); | ||
parentNode.appendChild(childNodeTwo); | ||
parentNode.appendChild(childNodeThree); | ||
const nodeList = parentNode.childNodes; | ||
|
||
document.getElementById('testNodeListLength').textContent = String(nodeList.length); | ||
})(); | ||
</script> | ||
</li> | ||
|
||
<li> | ||
<strong>values()</strong> | ||
<code id="testNodeListValues"></code> | ||
<script type="text/partytown"> | ||
(function () { | ||
const parentNode = document.createElement('div'); | ||
const childNodeOne = document.createElement('p'); | ||
const childNodeTwo = document.createElement('a'); | ||
const childNodeThree = document.createElement('span'); | ||
parentNode.appendChild(childNodeOne); | ||
parentNode.appendChild(childNodeTwo); | ||
parentNode.appendChild(childNodeThree); | ||
const nodeList = parentNode.childNodes; | ||
|
||
for (const value of nodeList.values()) { | ||
document.getElementById('testNodeListValues').textContent += value.nodeName + ' '; | ||
} | ||
})(); | ||
</script> | ||
</li> | ||
|
||
<li> | ||
<strong>Symbol.iterator</strong> | ||
<code id="testNodeListSymbolIterator"></code> | ||
<script type="text/partytown"> | ||
(function () { | ||
const parentNode = document.createElement('div'); | ||
const childNodeOne = document.createElement('p'); | ||
const childNodeTwo = document.createElement('a'); | ||
const childNodeThree = document.createElement('span'); | ||
parentNode.appendChild(childNodeOne); | ||
parentNode.appendChild(childNodeTwo); | ||
parentNode.appendChild(childNodeThree); | ||
const nodeList = parentNode.childNodes; | ||
|
||
for (const value of nodeList[Symbol.iterator]()) { | ||
document.getElementById('testNodeListSymbolIterator').textContent += | ||
value.nodeName + ' '; | ||
} | ||
})(); | ||
</script> | ||
</li> | ||
|
||
<script type="text/partytown"> | ||
(function () { | ||
document.body.className = 'completed'; | ||
})(); | ||
</script> | ||
</ul> | ||
|
||
<hr /> | ||
<p><a href="/tests/">All Tests</a></p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('node-list', async ({ page }) => { | ||
await page.goto('/tests/platform/node-list/'); | ||
|
||
await page.waitForSelector('.completed'); | ||
|
||
const testNodeList = page.locator('#testNodeList'); | ||
await expect(testNodeList).toHaveText('true'); | ||
|
||
const testNodeListEntries = page.locator('#testNodeListEntries'); | ||
await expect(testNodeListEntries).toHaveText('0 P 1 A 2 SPAN'); | ||
|
||
const testNodeListForEach = page.locator('#testNodeListForEach'); | ||
await expect(testNodeListForEach).toHaveText('P A SPAN'); | ||
|
||
const testNodeListItem = page.locator('#testNodeListItem'); | ||
await expect(testNodeListItem).toHaveText('P A SPAN'); | ||
|
||
const testNodeListKeys = page.locator('#testNodeListKeys'); | ||
await expect(testNodeListKeys).toHaveText('0 1 2'); | ||
|
||
const testNodeListLength = page.locator('#testNodeListLength'); | ||
await expect(testNodeListLength).toHaveText('3'); | ||
|
||
const testNodeListValues = page.locator('#testNodeListValues'); | ||
await expect(testNodeListValues).toHaveText('P A SPAN'); | ||
|
||
const testNodeListSymbolIterator = page.locator('#testNodeListSymbolIterator'); | ||
await expect(testNodeListSymbolIterator).toHaveText('P A SPAN'); | ||
}); |
f24fd22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
partytown – ./
partytown-builder-io.vercel.app
partytown-git-main-builder-io.vercel.app
partytown.vercel.app
partytown.builder.io