Skip to content

Commit

Permalink
minor grammar / clarifications
Browse files Browse the repository at this point in the history
  • Loading branch information
estelle authored Oct 6, 2023
1 parent 1ff52e9 commit 5d4e9a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions files/en-us/web/api/web_components/using_shadow_dom/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ If you click "Uppercase span elements", you'll see that {{domxref("Document.quer

## Element.shadowRoot and the "mode" option

In the example above, we pass an argument `{ mode: "open" }` to `attachShadow()`. With `mode` set to `"open"`, then JavaScript in the page is able to access the internals of your shadow DOM through the {{domxref("Element.shadowRoot", "shadowRoot")}} property of the shadow host.
In the example above, we pass an argument `{ mode: "open" }` to `attachShadow()`. With `mode` set to `"open"`, the JavaScript in the page is able to access the internals of your shadow DOM through the {{domxref("Element.shadowRoot", "shadowRoot")}} property of the shadow host.

In this example, as before, the HTML contains the shadow host, a `<span>` element in the main DOM tree, and two buttons:

Expand Down Expand Up @@ -168,7 +168,7 @@ This time, the JavaScript running in the page can access the shadow DOM internal

{{EmbedLiveSample("Element.shadowRoot and the \"mode\" option")}}

So `{mode: "open"}` gives the page a way to break the encapsulation of your shadow DOM. If you don't want to give the page this ability, pass `{mode: "closed"}` instead, and then `shadowRoot` returns `null`.
The `{mode: "open"}` argument gives the page a way to break the encapsulation of your shadow DOM. If you don't want to give the page this ability, pass `{mode: "closed"}` instead, and then `shadowRoot` returns `null`.

However, you should not consider this a strong security mechanism, because there are ways it can be evaded, for example by browser extensions running in the page. It's more of an indication that the page should not access the internals of your shadow DOM tree.

Expand Down

0 comments on commit 5d4e9a4

Please sign in to comment.