Skip to content

Commit 379c8c4

Browse files
Psychpsyoservo-wpt-sync
authored andcommitted
script: Implement forwarddelete command
Signed-off-by: Psychpsyo (Cameron) <60073468+Psychpsyo@users.noreply.github.com>
1 parent c937f9d commit 379c8c4

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
<!doctype html>
2-
<html>
2+
<html contentEditable="true">
33
<head>
44
<meta charset="utf-8">
5+
<title>ForwardDelete should not crash when trying to forwardDelete at the end of the document, outside of body.</title>
6+
<link rel="author" title="Psychpsyo" href="mailto:psychpsyo@gmail.com">
57
<script>
68
document.addEventListener("DOMContentLoaded", () => {
7-
const slot = document.createElement("slot");
8-
document.documentElement.appendChild(slot);
9-
const anchor = document.querySelector("a[contenteditable]");
10-
const selection = document.getSelection()
11-
getSelection().collapse(anchor, 0);
12-
getSelection().setBaseAndExtent(
13-
document, 0,
14-
document.documentElement, document.documentElement.childNodes.length
15-
);
16-
const range = selection.getRangeAt(0);
17-
document.documentElement.contentEditable = true;
18-
document.documentElement.contentEditable = false;
19-
range.collapse(false);
20-
getSelection().removeAllRanges();
21-
getSelection().addRange(range);
22-
document.documentElement.contentEditable = true;
9+
getSelection().selectAllChildren(document.documentElement);
10+
getSelection().collapseToEnd();
2311
document.execCommand("forwardDelete");
2412
});
2513
</script>
26-
</head><body>
27-
<a contenteditable></a>
28-
</body></html>
14+
</head>
15+
<body></body>
16+
<slot></slot>
17+
</html>

0 commit comments

Comments
 (0)