forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Update
Range::set_base_and_extent()
to latest spec
This allows it to work with content inside shadow roots.
- Loading branch information
Showing
3 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
Tests/LibWeb/Text/expected/set-selection-inside-shadow-root.txt
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,3 @@ | ||
After calling selection.setBaseAndExtent(): | ||
Selection range count: 1 | ||
Selection start offset: 0, end offset: 1 |
21 changes: 21 additions & 0 deletions
21
Tests/LibWeb/Text/input/set-selection-inside-shadow-root.html
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,21 @@ | ||
<script src="include.js"></script> | ||
<div id="root"></div> | ||
<script> | ||
function printSelectionDetails(selection) { | ||
println(`Selection range count: ${selection.rangeCount}`); | ||
if (selection.rangeCount > 0) | ||
println(`Selection start offset: ${selection.getRangeAt(0).startOffset}, end offset: ${selection.getRangeAt(0).endOffset}`); | ||
} | ||
|
||
test(() => { | ||
const rootElement = document.getElementById("root"); | ||
const shadowRoot = rootElement.attachShadow({ mode: "open" }); | ||
shadowRoot.innerHTML = "This is some text"; | ||
const selection = window.getSelection(); | ||
selection.setBaseAndExtent(shadowRoot, 0, shadowRoot, 1); | ||
println("After calling selection.setBaseAndExtent():"); | ||
printSelectionDetails(selection); | ||
|
||
shadowRoot.innerHTML = ""; | ||
}); | ||
</script> |
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