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 initial content for getHTML #33494

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
50 changes: 50 additions & 0 deletions files/en-us/web/api/element/gethtml/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "Element: getHTML() method"
short-title: getHTML()
slug: Web/API/Element/getHTML
page-type: web-api-instance-method
browser-compat: api.Element.getHTML
---

{{APIRef("DOM")}}{{SeeCompatTable}}{{SecureContext_Header}}

The **`getHTML()`** method of the {{domxref("Element")}} interface is used to serialize an Element's DOM to an HTML string.
sideshowbarker marked this conversation as resolved.
Show resolved Hide resolved

## Syntax

```js-nolint
const html = element.getHTML(options)
```

### Parameters

- `options` {{optional_inline}}

- : 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`.
- `shadowRoots`
- : An array of {{domxref("ShadowRoot")}} objects to serialize, these are included regardless of whether they
sideshowbarker marked this conversation as resolved.
Show resolved Hide resolved
are marked as serializable. The default value is an empty array.

### Return value

A string that represents the HTML serialization of the Element.
sideshowbarker marked this conversation as resolved.
Show resolved Hide resolved

### Exceptions

None.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See Also

- {{domxref("ShadowRoot.getHTML()")}}
- {{domxref("Element.innerHTML")}}
49 changes: 49 additions & 0 deletions files/en-us/web/api/shadowroot/gethtml/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "ShadowRoot: getHTML() method"
short-title: getHTML()
slug: Web/API/ShadowRoot/getHTML
page-type: web-api-instance-method
browser-compat: api.ShadowRoot.getHTML
---

{{APIRef("DOM")}}{{SeeCompatTable}}{{SecureContext_Header}}

The **`getHTML()`** method of the {{domxref("ShadowRoot")}} interface is used to serialize a ShadowRoot's DOM to an HTML string.
sideshowbarker marked this conversation as resolved.
Show resolved Hide resolved

## Syntax

```js-nolint
const html = shadowRoot.getHTML(options)
```

### Parameters

- `options` {{optional_inline}}

- : 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`.
- `shadowRoots`
- : An array of {{domxref("ShadowRoot")}} objects to serialize, these are included regardless of whether they
sideshowbarker marked this conversation as resolved.
Show resolved Hide resolved
are marked as serializable. The default value is an empty array.

### Return value

A string that represents the HTML serialization of the ShadowRoot.
sideshowbarker marked this conversation as resolved.
Show resolved Hide resolved

### Exceptions

None.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See Also

- {{domxref("ShadowRoot.innerHTML")}}