Skip to content

Commit 0ba1a57

Browse files
committed
switch from shadowroot= to shadowrootmode=
1 parent 6904be9 commit 0ba1a57

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

STYLEGUIDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ concepts, for example always use Declarative Shadow DOM. As a general rule, if y
241241
your prose, then don't use it.
242242

243243
Concepts are useful for capturing a group of APIs, or a technique. For example a Declarative ShadowDOM refers to a
244-
`template` with a `shadowroot=` _attribute_ inside of HTML. A concept needs to be set up before its use on a page, but
245-
once it has been explained, you can continue to refer to it without having to recover the APIs it's comprised of.
244+
`template` with a `shadowrootmode=` _attribute_ inside of HTML. A concept needs to be set up before its use on a page,
245+
but once it has been explained, you can continue to refer to it without having to recover the APIs it's comprised of.
246246

247247
## Ending notes, summaries
248248

learn/components/rendering.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ class StopWatchElement extends HTMLElement {
8282
If you don't want to define the template within JavaScript, you can instead define it up-front in the HTML of your
8383
component with a _declarative ShadowDOM template_. When you define a _declarative ShadowDOM template_ the browser will
8484
handle attaching a _shadow root_ and cloning the contents of the template for you. To do this, you'll need to add a
85-
`<template>` tag as a child of your element, with a `shadowroot` attribute:
85+
`<template>` tag as a child of your element, with a `shadowrootmode` attribute:
8686

8787
```html
8888
<stop-watch>
89-
<template shadowroot="open">
89+
<template shadowrootmode="open">
9090
<p>Hello World</p>
9191
</template>
9292
</stop-watch>
@@ -143,10 +143,10 @@ class StopWatchElement extends HTMLElement {
143143
### Advanced: Using a closed _ShadowDOM_
144144

145145
You might have noticed that `attachShadow()` has to be passed `mode: 'open'` (and similarly _declarative ShadowDOM_ is
146-
created using `<template shadowroot="open">`). This tells the ShadowRoot to be in "open" mode, which makes it public.
147-
Other elements will be able to access an open ShadowRoot via the `.shadowRoot` property - even if you don't set it
148-
yourself. Generally speaking, open ShadowRoots are the best choice; they still offer good isolation and are easy to work
149-
with.
146+
created using `<template shadowrootmode="open">`). This tells the ShadowRoot to be in "open" mode, which makes it
147+
_public_. Other elements will be able to access an open ShadowRoot via the `.shadowRoot` property - even if you don't
148+
set it yourself. Generally speaking, open ShadowRoots are the best choice; they still offer good isolation and are easy
149+
to work with.
150150

151151
Another option, however, is to set it to `mode: 'closed'`. This makes your ShadowRoot private. A _closed ShadowRoot_
152152
**will not** be accessible via `.shadowRoot` (unless you intentionally assign it to `.shadowRoot`). It will also change
@@ -190,7 +190,7 @@ one can also get the _closed ShadowRoot_:
190190

191191
```html
192192
<stop-watch>
193-
<template shadowroot="closed">
193+
<template shadowrootmode="closed">
194194
<p>Hello World</p>
195195
</template>
196196
</stop-watch>

learn/components/styling.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ boundary unintentionally. This is different to regular CSS where a selector can
2121
<p>This text is deeppink and not teal because it is outside of the shadow root.</p>
2222

2323
<fancy-p>
24-
<template shadowroot="open">
24+
<template shadowrootmode="open">
2525
<style>
2626
p {
2727
color: teal;
@@ -52,7 +52,7 @@ element itself (also known as the shadow host).
5252
<article>
5353
<h1>This text is deeppink.</h1>
5454
<article-meta>
55-
<template shadowroot="open">
55+
<template shadowrootmode="open">
5656
<style>
5757
span {
5858
font-style: italic;
@@ -80,7 +80,7 @@ styles to the custom element, aka the _shadow host_:
8080

8181
```html
8282
<fancy-p>
83-
<template shadowroot="open">
83+
<template shadowrootmode="open">
8484
<style>
8585
:host {
8686
display: inline-block;
@@ -113,7 +113,7 @@ it will select elements within the shadow tree.
113113

114114
```html
115115
<fancy-p>
116-
<template shadowroot="open">
116+
<template shadowrootmode="open">
117117
<style>
118118
:host > p {
119119
color: deeppink;
@@ -132,7 +132,7 @@ selector. Specifying a selector can be useful for styling specific elements in p
132132

133133
```html
134134
<fancy-elements>
135-
<template shadowroot="open">
135+
<template shadowrootmode="open">
136136
<style>
137137
::slotted(button) {
138138
color: deeppink;
@@ -153,7 +153,7 @@ If you want to target elements in specific slots you can pass an attribute selec
153153

154154
```html
155155
<fancy-article>
156-
<template shadowroot="open">
156+
<template shadowrootmode="open">
157157
<style>
158158
::slotted([slot="title"]) {
159159
font-size: 2rem;
@@ -210,7 +210,7 @@ fancy-article::part(content) {
210210

211211
```html
212212
<fancy-article>
213-
<template shadowroot="open">
213+
<template shadowrootmode="open">
214214
<article part="article">
215215
<hgroup part="header">
216216
<slot name="title"></slot>

script/polyfills.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import "construct-style-sheets-polyfill"
55

66
/* Declarative ShadowDOM polyfill */
77
function attachShadowRoots(root) {
8-
root.querySelectorAll("template[shadowroot]").forEach((template) => {
9-
const mode = template.getAttribute("shadowroot")
8+
root.querySelectorAll("template[shadowrootmode]").forEach((template) => {
9+
const mode = template.getAttribute("shadowrootmode")
1010
const shadowRoot = template.parentNode.attachShadow({ mode })
1111
shadowRoot.appendChild(template.content)
1212
template.remove()

0 commit comments

Comments
 (0)