Skip to content

Commit

Permalink
migrate to shadowrootmode attribute (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Dec 28, 2023
1 parent 754b6af commit 06309e3
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
1. Get HTML!
```html
<wcc-footer>
<template shadowroot="open">
<template shadowrootmode="open">
<style>
.footer {
color: white;
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class Counter extends HTMLElement {
render() {
return `
<template shadowroot="open">
<template shadowrootmode="open">
<script type="application/json">
${JSON.stringify({ count: this.count })}
</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $ npm install wc-compiler --save-dev
1. You will get the following HTML output that can be used in conjunction with your preferred site framework or templating solution.
```html
<wcc-footer>
<template shadowroot="open">
<template shadowrootmode="open">
<style>
.footer {
color: white;
Expand Down
2 changes: 1 addition & 1 deletion src/dom-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class HTMLTemplateElement extends HTMLElement {
set innerHTML(html) {
if (this.content) {
this.content.innerHTML = `
<template shadowroot="open">
<template shadowrootmode="open">
${html}
</template>
`;
Expand Down
4 changes: 2 additions & 2 deletions test/cases/attributes/attributes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Run WCC For ', function() {

describe(LABEL, function() {
it('should have one top level <wcc-counter> custom element with a <template> with an open shadowroot', function() {
expect(dom.window.document.querySelectorAll('wcc-counter template[shadowroot="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('wcc-counter template[shadowrootmode="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('wcc-counter template').length).to.equal(1);
});

Expand All @@ -44,7 +44,7 @@ describe('Run WCC For ', function() {
let counterContentsDom;

before(function() {
counterContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-counter template[shadowroot="open"]')[0].innerHTML);
counterContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-counter template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have two <button> tags within the <wcc-counter> shadowroot', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/cases/attributes/src/components/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Counter extends HTMLElement {

render() {
return `
<template shadowroot="open">
<template shadowrootmode="open">
<div>
<button id="inc">Increment</button>
<span>Current Count: <span id="count">${this.count}</span></span>
Expand Down
6 changes: 3 additions & 3 deletions test/cases/children-and-slots/children-and-slots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ describe('Run WCC For ', function() {

describe(LABEL, function() {
it('should have one two top level <wcc-paragraph> custom elements with a <template> with an open shadowroot', function() {
expect(dom.window.document.querySelectorAll('wcc-paragraph template[shadowroot="open"]').length).to.equal(2);
expect(dom.window.document.querySelectorAll('wcc-paragraph template[shadowrootmode="open"]').length).to.equal(2);
expect(dom.window.document.querySelectorAll('wcc-paragraph template').length).to.equal(2);
});

describe('<my-paragraph> with default <slot> content', function() {
let paragraphContentsDom;

before(function() {
paragraphContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-paragraph.default template[shadowroot="open"]')[0].innerHTML);
paragraphContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-paragraph.default template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have one <my-paragraph> tag for the default content', function() {
Expand All @@ -56,7 +56,7 @@ describe('Run WCC For ', function() {
let paragraphContentsLightDom;

before(function() {
paragraphContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-paragraph.custom template[shadowroot="open"]')[0].innerHTML);
paragraphContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-paragraph.custom template[shadowrootmode="open"]')[0].innerHTML);
paragraphContentsLightDom = new JSDOM(dom.window.document.querySelectorAll('wcc-paragraph.custom')[0].innerHTML);
});

Expand Down
4 changes: 2 additions & 2 deletions test/cases/custom-extension/custom-extension.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ describe('Run WCC For ', function() {
});

it('should have one top level <wcc-footer> element with a <template> with an open shadowroot', function() {
expect(dom.window.document.querySelectorAll('wcc-footer template[shadowroot="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('wcc-footer template[shadowrootmode="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('template').length).to.equal(1);
});

describe('<footer> component and content', function() {
let footer;

before(async function() {
footer = new JSDOM(dom.window.document.querySelectorAll('wcc-footer template[shadowroot="open"]')[0].innerHTML);
footer = new JSDOM(dom.window.document.querySelectorAll('wcc-footer template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have one <footer> tag within the <template> shadowroot', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/cases/get-data/get-data.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Run WCC For ', function() {

describe(LABEL, function() {
it('should have one top level <wcc-counter> custom element with a <template> with an open shadowroot', function() {
expect(dom.window.document.querySelectorAll('wcc-counter template[shadowroot="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('wcc-counter template[shadowrootmode="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('wcc-counter template').length).to.equal(1);
});

Expand All @@ -45,7 +45,7 @@ describe('Run WCC For ', function() {
let count;

before(function() {
counterContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-counter template[shadowroot="open"]')[0].innerHTML);
counterContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-counter template[shadowrootmode="open"]')[0].innerHTML);
count = JSON.parse(counterContentsDom.window.document.querySelector('script[type="application/json"]').textContent).count;
});

Expand Down
2 changes: 1 addition & 1 deletion test/cases/get-data/src/components/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Counter extends HTMLElement {

render() {
return `
<template shadowroot="open">
<template shadowrootmode="open">
<script type="application/json">
${JSON.stringify({ count: this.count })}
</script>
Expand Down
10 changes: 5 additions & 5 deletions test/cases/nested-elements/nested-elements.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ describe('Run WCC For ', function() {
const { html } = await renderToString(new URL('./src/pages/index.js', import.meta.url));

dom = new JSDOM(html);
pageContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-home template[shadowroot="open"]')[0].innerHTML);
pageContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-home template[shadowrootmode="open"]')[0].innerHTML);
});

describe(LABEL, function() {
it('should have one top level <template> with an open shadowroot', function() {
expect(dom.window.document.querySelectorAll('template[shadowroot="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('template[shadowrootmode="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('template').length).to.equal(1);
});

describe('custom footer element', function() {
let footerContentsDom;

before(function() {
footerContentsDom = new JSDOM(pageContentsDom.window.document.querySelectorAll('wcc-footer template[shadowroot="open"]')[0].innerHTML);
footerContentsDom = new JSDOM(pageContentsDom.window.document.querySelectorAll('wcc-footer template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have a <footer> tag within the <template> shadowroot', function() {
Expand All @@ -68,7 +68,7 @@ describe('Run WCC For ', function() {
let headerContentsDom;

before(function() {
headerContentsDom = new JSDOM(pageContentsDom.window.document.querySelectorAll('wcc-header template[shadowroot="open"]')[0].innerHTML);
headerContentsDom = new JSDOM(pageContentsDom.window.document.querySelectorAll('wcc-header template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have a <header> tag within the <template> shadowroot', function() {
Expand All @@ -85,7 +85,7 @@ describe('Run WCC For ', function() {
let navigationContentsDom;

before(function() {
navigationContentsDom = new JSDOM(headerContentsDom.window.document.querySelectorAll('wcc-navigation template[shadowroot="open"]')[0].innerHTML);
navigationContentsDom = new JSDOM(headerContentsDom.window.document.querySelectorAll('wcc-navigation template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have a <nav> tag within the <template> shadowroot', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/cases/nested-elements/src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Header extends HTMLElement {

render() {
return `
<template shadowroot="open">
<template shadowrootmode="open">
<header class="header">
<div class="head-wrap">
<div class="brand">
Expand Down
4 changes: 2 additions & 2 deletions test/cases/render-from-html/render-from-html.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Run WCC ', function() {
let headerContentsDom;

before(function() {
headerContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-header template[shadowroot="open"]')[0].innerHTML);
headerContentsDom = new JSDOM(dom.window.document.querySelectorAll('wcc-header template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have a <header> tag within the <template> shadowroot', function() {
Expand All @@ -88,7 +88,7 @@ describe('Run WCC ', function() {
let navigationContentsDom;

before(function() {
navigationContentsDom = new JSDOM(headerContentsDom.window.document.querySelectorAll('wcc-navigation template[shadowroot="open"]')[0].innerHTML);
navigationContentsDom = new JSDOM(headerContentsDom.window.document.querySelectorAll('wcc-navigation template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have a <nav> tag within the <template> shadowroot', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/cases/single-element/single-element.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ describe('Run WCC For ', function() {
});

it('should have one top level <wcc-footer> element with a <template> with an open shadowroot', function() {
expect(dom.window.document.querySelectorAll('wcc-footer template[shadowroot="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('wcc-footer template[shadowrootmode="open"]').length).to.equal(1);
expect(dom.window.document.querySelectorAll('template').length).to.equal(1);
});

describe('<footer> component and content', function() {
let footer;

before(async function() {
footer = new JSDOM(dom.window.document.querySelectorAll('wcc-footer template[shadowroot="open"]')[0].innerHTML);
footer = new JSDOM(dom.window.document.querySelectorAll('wcc-footer template[shadowrootmode="open"]')[0].innerHTML);
});

it('should have one <footer> tag within the <template> shadowroot', function() {
Expand Down

0 comments on commit 06309e3

Please sign in to comment.