From 1691f94d25b3e3caca5acf2552ae6ce6366b8fe9 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 14 May 2024 13:38:52 +1000 Subject: [PATCH 1/8] Add docs for shadow root serializable property (everywhere) --- .../web/api/element/attachshadow/index.md | 6 +++ files/en-us/web/api/element/gethtml/index.md | 11 ++++-- .../web/api/htmltemplateelement/index.md | 4 ++ .../shadowrootserializable/index.md | 32 +++++++++++++++ .../en-us/web/api/shadowroot/gethtml/index.md | 9 +++-- files/en-us/web/api/shadowroot/index.md | 8 +++- .../web/api/shadowroot/serializable/index.md | 39 +++++++++++++++++++ .../en-us/web/html/element/template/index.md | 11 ++++-- 8 files changed, 108 insertions(+), 12 deletions(-) create mode 100644 files/en-us/web/api/htmltemplateelement/shadowrootserializable/index.md create mode 100644 files/en-us/web/api/shadowroot/serializable/index.md diff --git a/files/en-us/web/api/element/attachshadow/index.md b/files/en-us/web/api/element/attachshadow/index.md index e6fdc1be2e45f1d..ea37a4648496c86 100644 --- a/files/en-us/web/api/element/attachshadow/index.md +++ b/files/en-us/web/api/element/attachshadow/index.md @@ -83,6 +83,12 @@ attachShadow(options) - : A boolean that, when set to `true`, specifies behavior that mitigates custom element issues around focusability. When a non-focusable part of the shadow DOM is clicked, the first focusable part is given focus, and the shadow host is given any available `:focus` styling. Its default value is `false`. + - `serializable` {{Optional_Inline}} + + - : A boolean that, when set to `true`, indicates that the shadow root is serializable. + Its default value is `false`. + If set, the shadow root may be serialized by calling the {{DOMxRef('Element.getHTML()')}} or {{DOMxRef('ShadowRoot.getHTML()')}} methods with the `options.serializableShadowRoots` parameter set `true`. + - `slotAssignment` {{Optional_inline}} - : A string specifying the _slot assignment mode_ for the shadow DOM tree. This can be one of: diff --git a/files/en-us/web/api/element/gethtml/index.md b/files/en-us/web/api/element/gethtml/index.md index 133d548ca0b4091..7d4fbdf49691ab1 100644 --- a/files/en-us/web/api/element/gethtml/index.md +++ b/files/en-us/web/api/element/gethtml/index.md @@ -12,10 +12,12 @@ browser-compat: api.Element.getHTML The **`getHTML()`** method of the {{domxref("Element")}} interface is used to serialize an element's DOM to an HTML string. +The serialized HTML does not include shadow trees by default, but options can be used to include shadow roots that have been set as {{domxref("ShadowRoot/serializable","serializable")}}, and/or a specified array of {{domxref("ShadowRoot")}} objects. + ## Syntax ```js-nolint -const html = element.getHTML(options) +getHTML(options) ``` ### Parameters @@ -25,10 +27,11 @@ const html = element.getHTML(options) - : An options object with the following optional parameters: - `serializableShadowRoots` - - : A boolean value that specifies whether to include serializable shadow roots. The default value is `false`. + - : A boolean value that specifies whether to include {{domxref("ShadowRoot/serializable","serializable")}} shadow roots. + The default value is `false`. - `shadowRoots` - - : An array of {{domxref("ShadowRoot")}} objects to serialize. These are included regardless of whether they - are marked as serializable. The default value is an empty array. + - : An array of {{domxref("ShadowRoot")}} objects to serialize. These are included regardless of whether they are marked as `serializable`. + The default value is an empty array. ### Return value diff --git a/files/en-us/web/api/htmltemplateelement/index.md b/files/en-us/web/api/htmltemplateelement/index.md index 4a0af007a0e9000..35a156ed47d0f78 100644 --- a/files/en-us/web/api/htmltemplateelement/index.md +++ b/files/en-us/web/api/htmltemplateelement/index.md @@ -20,6 +20,7 @@ The **`HTMLTemplateElement`** interface enables access to the contents of an HTM _This interface inherits the properties of {{domxref("HTMLElement")}}._ - {{domxref("HTMLTemplateElement.content", "content")}} {{ReadOnlyInline}} + - : A read-only {{domxref("DocumentFragment")}} which contains the DOM subtree representing the {{HTMLElement("template")}} element's template contents. - {{domxref("HTMLTemplateElement.shadowRootMode", "shadowRootMode")}} - : A string that reflects the value of the [`shadowrootmode`](/en-US/docs/Web/HTML/Element/template#shadowrootmode) attribute of the associated `