LibWeb: Update Element::directionality() to match current spec text

This fixes a crash that occurred when determining the directionality of
input elements.
This commit is contained in:
Tim Ledbetter
2024-05-04 14:47:04 +01:00
committed by Andrew Kaster
parent 23473d64ca
commit 57f0ea186e
Notes: sideshowbarker 2024-07-17 01:53:23 +09:00
4 changed files with 244 additions and 107 deletions

View File

@@ -0,0 +1,44 @@
<!DOCTYPE html>
<style>
.test {
font-size: 12px;
}
</style>
<script src="../include.js"></script>
<script>
test(() => {
function testSelectorMatch(input, selector) {
println(`Input matches ${selector}: ${input.matches(selector)}`);
}
const input = document.createElement("input");
input.type = "text";
input.value = "Well hello friends!"
testSelectorMatch(input, ":dir(ltr)");
testSelectorMatch(input, ":dir(rtl)");
input.dir = "invalid";
testSelectorMatch(input, ":dir(ltr)");
testSelectorMatch(input, ":dir(rtl)");
input.dir = "rtl";
testSelectorMatch(input, ":dir(ltr)");
testSelectorMatch(input, ":dir(rtl)");
input.dir = "auto"
testSelectorMatch(input, ":dir(ltr)");
testSelectorMatch(input, ":dir(rtl)");
input.value = "حسنًا ، مرحباً أيها الأصدقاء";
testSelectorMatch(input, ":dir(ltr)");
testSelectorMatch(input, ":dir(rtl)");
input.dir = "ltr"
testSelectorMatch(input, ":dir(ltr)");
testSelectorMatch(input, ":dir(rtl)");
input.removeAttribute("dir");
testSelectorMatch(input, ":dir(ltr)");
testSelectorMatch(input, ":dir(rtl)");
});
</script>