Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clonable option and attribute #31849

Merged
merged 5 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions files/en-us/web/api/element/attachshadow/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ attachShadow(options)
element.shadowRoot; // Returns null
```

- `clonable` {{Optional_Inline}}

- : A boolean that specifies whether the shadow root is clonable: when set to `true`, the shadow host cloned with {{domxref("Node.cloneNode()")}} or {{domxref("Document.importNode()")}} will include shadow root in the copy. Its default value is `false`, unless the shadow root is created via declarative shadow DOM.

- `delegatesFocus` {{Optional_Inline}}

- : A boolean that, when set to `true`, specifies behavior that mitigates custom element issues around focusability.
Expand Down
32 changes: 32 additions & 0 deletions files/en-us/web/api/shadowroot/clonable/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: "ShadowRoot: clonable property"
short-title: clonable
slug: Web/API/ShadowRoot/clonable
page-type: web-api-instance-property
browser-compat: api.ShadowRoot.clonable
---

{{APIRef("Shadow DOM")}}

The **`clonable`** read-only property of the {{domxref("ShadowRoot")}} interface returns `true` if the shadow root is clonable, and `false` otherwise. It's always returns `true` for shadow roots created via declarative shadow DOM or can be set via {{domxref("Element.attachShadow()")}} `clonable` option.
pepelsbey marked this conversation as resolved.
Show resolved Hide resolved

## Examples

```js
const host = document.createElement("div");
const shadowRoot = host.attachShadow({
mode: "open",
clonable: true,
});

shadowRoot.clonable;
// true
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
2 changes: 2 additions & 0 deletions files/en-us/web/api/shadowroot/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ You can retrieve a reference to an element's shadow root using its {{domxref("El
- {{domxref("ShadowRoot.adoptedStyleSheets")}}
- : Add an array of constructed stylesheets to be used by the shadow DOM subtree.
These may be shared with other DOM subtrees that share the same parent {{domxref("Document")}} node, and the document itself.
- {{domxref("ShadowRoot.clonable")}} {{ReadOnlyInline}}
- : Returns a boolean that indicates whether the shadow root is clonable, which can be set via {{domxref("Element.attachShadow()")}} `clonable` option.
pepelsbey marked this conversation as resolved.
Show resolved Hide resolved
- {{domxref("ShadowRoot.delegatesFocus")}} {{ReadOnlyInline}}
- : Returns a boolean that indicates whether `delegatesFocus` was set when the shadow was attached (see {{domxref("Element.attachShadow()")}}).
- {{DOMxRef("ShadowRoot.fullscreenElement")}} {{ReadOnlyInline}}
Expand Down