-
Notifications
You must be signed in to change notification settings - Fork 22.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial content for setHTMLUnsafe and parseHTMLUnsafe
- Loading branch information
1 parent
e04783b
commit ee3aa4c
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
files/en-us/web/api/document/parsehtmlunsafe_static/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: "Document: parseHTMLUnsafe() static method" | ||
short-title: parseHTMLUnsafe() | ||
slug: Web/API/Document/parseHTMLUnsafe_static | ||
page-type: web-api-static-method | ||
browser-compat: api.Document.parseHTMLUnsafe_static | ||
--- | ||
|
||
{{APIRef("DOM")}}{{SeeCompatTable}}{{SecureContext_Header}} | ||
|
||
The **`Document.parseHTMLUnsafe()`** static method is used to parse a string of HTML as a new document object. | ||
|
||
## Syntax | ||
|
||
```js-nolint | ||
const doc = Document.parseHTMLUnsafe(input) | ||
``` | ||
|
||
### Parameters | ||
|
||
- `input` | ||
- : A string defining HTML to be parsed. | ||
|
||
### Return value | ||
|
||
A {{domxref("Document")}}. | ||
|
||
### Exceptions | ||
|
||
None. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- Parsing HTML or XML into a DOM tree: {{domxref("DOMParser")}} | ||
- {{domxref("Element.setHTMLUnsafe")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "Element: setHTMLUnsafe() method" | ||
short-title: setHTMLUnsafe() | ||
slug: Web/API/Element/setHTMLUnsafe | ||
page-type: web-api-instance-method | ||
browser-compat: api.Element.setHTMLUnsafe | ||
--- | ||
|
||
{{APIRef("DOM")}}{{SeeCompatTable}}{{SecureContext_Header}} | ||
|
||
The **`setHTMLUnsafe()`** method of the {{domxref("Element")}} interface is used to parse a string of HTML and then insert it into the DOM as a subtree of the element. | ||
|
||
## Syntax | ||
|
||
```js-nolint | ||
element.setHTMLUnsafe(input) | ||
``` | ||
|
||
### Parameters | ||
|
||
- `input` | ||
- : A string defining HTML to be parsed. | ||
|
||
### Return value | ||
|
||
None (`undefined`). | ||
|
||
### Exceptions | ||
|
||
None. | ||
|
||
## Examples | ||
|
||
The code below demonstrates how to parse a string of HTML and insert it into the `Element` with an id of `target`. | ||
|
||
```js | ||
const value = "<p>This is a string of text</p>"; // string of HTML | ||
|
||
// Get the Element with id "target" and set it with the string. | ||
document.getElementById("target").setHTMLUnsafe(value); | ||
|
||
// Result (as a string): "<p>This is a string of text</p>" | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("Element.innerHTML")}} | ||
- {{domxref("Document.parseHTMLUnsafe_static")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: "ShadowRoot: setHTMLUnsafe() method" | ||
short-title: setHTMLUnsafe() | ||
slug: Web/API/ShadowRoot/setHTMLUnsafe | ||
page-type: web-api-instance-method | ||
browser-compat: api.ShadowRoot.setHTMLUnsafe | ||
--- | ||
|
||
{{APIRef("DOM")}}{{SeeCompatTable}}{{SecureContext_Header}} | ||
|
||
The **`setHTMLUnsafe()`** method of the {{domxref("ShadowRoot")}} interface is used to parse a string of HTML and then insert it into the DOM as a subtree of the shadow root. | ||
|
||
## Syntax | ||
|
||
```js-nolint | ||
shadowRoot.setHTMLUnsafe(input) | ||
``` | ||
|
||
### Parameters | ||
|
||
- `input` | ||
- : A string defining HTML to be parsed. | ||
|
||
### Return value | ||
|
||
None (`undefined`). | ||
|
||
### Exceptions | ||
|
||
None. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("ShadowRoot.innerHTML")}} | ||
- {{domxref("Document.parseHTMLUnsafe_static")}} |