Skip to content

Commit 4be5fbe

Browse files
authored
[breaking changes] Migrate to shadowrootmode support and modernize testing (#43)
1 parent 62ca556 commit 4be5fbe

13 files changed

+3801
-12757
lines changed

.github/workflows/test.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ jobs:
1111
- uses: actions/checkout@v2
1212
- uses: actions/setup-node@v1
1313
with:
14-
node-version: 12
14+
node-version: 18
1515

1616
- name: NPM install
1717
run: npm ci
1818

1919
- name: Build
2020
run: npm run build
2121

22+
- name: Install playwright browsers
23+
run: npx playwright install-deps
24+
2225
- name: Test
2326
run: npm test

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ A [ponyfill](https://ponyfill.com/) of the API described by Mason Freed at https
66

77
## Overview
88

9-
This package provides a function, `hydrateShadowRoots`, that converts `<template>` elements with a `shadowroot` attribute into ShadowRoots on the template's parent element.
9+
This package provides a function, `hydrateShadowRoots`, that converts `<template>` elements with a `shadowrootmode` attribute into ShadowRoots on the template's parent element.
1010

1111
This allows HTML with shadow roots to be serialized to plain HTML, and the serialized shadow roots "rehydrated" (separate from component hydration) on the client.
1212

13-
`<template shadowroot>` elements are transformed bottom up so that in the case where they're nested, all elements within the declarative shadow tree stay inert until they have all been moved from their `<template shadowroot>` elements.
13+
`<template shadowrootmode>` elements are transformed bottom up so that in the case where they're nested, all elements within the declarative shadow tree stay inert until they have all been moved from their `<template shadowrootmode>` elements.
1414

15-
If native support for `<template shadowroot>` is present, `hydrateShadowRoots` does nothing when called.
15+
If native support for `<template shadowrootmode>` is present, `hydrateShadowRoots` does nothing when called.
1616

1717
### Known limitations
1818

1919
* Does not currently look into imperatively created shadow roots.
2020
* The mutation observer implementation
2121
* May not work properly in the face of streaming HTML parsing. Needs investigation.
22-
* Will not notice imperatively created `<template shadowroot>` elements inside of other shadow roots.
22+
* Will not notice imperatively created `<template shadowrootmode>` elements inside of other shadow roots.
2323
* Not enough benchmarks, and benchmarks of insufficient quality to be confident of good performance.

bench/many_deep.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
const n = 1000;
2828
for (let i = 0; i < n; i++) {
2929
html += `<div>
30-
<template shadowroot="open">
30+
<template shadowrootmode="open">
3131
`;
3232
}
3333
for (let i = 0; i < n; i++) {

bench/many_flat.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
const html = `
2727
<div>
28-
<template shadowroot="open">
28+
<template shadowrootmode="open">
2929
<div>Hello world</div>
3030
</template>
3131
</div>

karma.conf.cjs

-65
This file was deleted.

0 commit comments

Comments
 (0)