Skip to content

Commit a02fb4e

Browse files
Erzenderdipikabh
andauthored
Update inconsistent var name in example (mdn#40393)
* Update inconsistent var name in example * fixing few more instances --------- Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
1 parent 933dc28 commit a02fb4e

File tree

1 file changed

+4
-4
lines changed
  • files/en-us/web/api/html_sanitizer_api/using_the_html_sanitizer_api

1 file changed

+4
-4
lines changed

files/en-us/web/api/html_sanitizer_api/using_the_html_sanitizer_api/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ For example, the following code will remove all XSS-unsafe elements and attribut
1818

1919
```js
2020
const untrustedString = "abc <script>alert(1)<" + "/script> def";
21-
const someTargetElement = document.getElementById("target");
21+
const someElement = document.getElementById("target");
2222

2323
// someElement.innerHTML = untrustedString;
2424
someElement.setHTML(untrustedString);
2525

26-
console.log(target.innerHTML); // abc def
26+
console.log(someElement.innerHTML); // abc def
2727
```
2828

2929
The other XSS-safe methods, {{domxref('ShadowRoot.setHTML()')}} and {{domxref('Document/parseHTML_static','Document.parseHTML()')}}, are used in the same way.
@@ -54,7 +54,7 @@ For example, in the following sanitizer all safe elements are allowed, and we fu
5454

5555
```js
5656
const untrustedString = '<button onclick="alert(1)">Button text</button>';
57-
const someTargetElement = document.getElementById("target");
57+
const someElement = document.getElementById("target");
5858

5959
sanitizerOne = Sanitizer(); // Default sanitizer
6060
sanitizerOne.allowElement({ name: "button", attributes: ["onclick"] });
@@ -211,7 +211,7 @@ targetElement.setHTML("This <b>highlighting</b> isn't needed", {
211211
});
212212

213213
// Log the result
214-
targetElement.log(targetElement.innerHTML); // This highlighting isn't needed
214+
console.log(targetElement.innerHTML); // This highlighting isn't needed
215215
```
216216

217217
As with elements and attributes, you can also specify the replacement elements with a namespace, or use the {{domxref("Sanitizer.replaceElementWithChildren()")}} method:

0 commit comments

Comments
 (0)