Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix :out-of-range pseudo class matching for empty input[type=number]
Fix :out-of-range pseudo class matching for empty input[type=number] https://bugs.webkit.org/show_bug.cgi?id=249642 Reviewed by Aditya Keerthi. This patch is to align WebKit behavior with Gecko / Firefox, Blink / Chromium and Web-Specification. Merge - https://chromium.googlesource.com/chromium/blink/+/37a451a5e2b2b571871560111eb164ced3df1240 The definition of :out-of-range is 'either rangeUnderflow or rangeOverflow.' If an INPUT has no value, neither rangeUnderflow nor rangeOverflow is true. * Source/WebCore/html/InputType.cpp: (InputType::isInRange): Add comment for return value (InputType::isOutOfRange): Add comment for return value and also change it to "false" * LayoutTests/fast/css/pseudo-out-of-range.html: Updated * LayoutTests/fast/css/pseudo-out-of-range-expected.txt: Ditto * LayoutTests/fast/css/pseudo-in-range.html: Ditto * LayoutTests/fast/css/pseudo-in-range-expected.txt: Ditto Canonical link: https://commits.webkit.org/258165@main
- Loading branch information
1 parent
4a35ca3
commit c427ef22b3af7c014053c01382a8113d06e9f6e8
Showing
5 changed files
with
37 additions
and
15 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,20 +1,25 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<script src="../../resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description('Tests that we find controls if they have a range limitation and are in-range.'); | ||
|
||
var parentDiv = document.createElement('div'); | ||
document.body.appendChild(parentDiv); | ||
parentDiv.innerHTML = '<input id="number1" type="number" min=0 max=10 value=5><input id="range1" type="range" min=0 max=10 value=5><input id="text1" type="text" min=0 max=10 value=5><input id="checkbox1" type="checkbox"> <input id="radio1" type="radio">'; | ||
parentDiv.innerHTML = '<input id="number1" type="number" min=0 max=10><input id="range1" type="range" min=0 max=10 value=5><input id="text1" type="text" min=0 max=10 value=5><input id="checkbox1" type="checkbox"> <input id="radio1" type="radio">'; | ||
|
||
shouldBe('document.querySelector("input[type=number]:in-range").id', '"number1"'); | ||
shouldBe('document.querySelector("input[type=range]:in-range").id', '"range1"'); | ||
debug('==> :in-range should match to an INPUT without a value:'); | ||
shouldBeEqualToString('document.querySelector("input[type=number]:in-range").id', 'number1'); | ||
|
||
debug(''); | ||
debug('==> :in-range should match to an INPUT with an in-range value:'); | ||
parentDiv.firstChild.value = '5'; | ||
shouldBeEqualToString('document.querySelector("input[type=number]:in-range").id', 'number1'); | ||
shouldBeEqualToString('document.querySelector("input[type=range]:in-range").id', 'range1'); | ||
shouldBe('document.querySelectorAll(":in-range").length', '2'); | ||
</script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</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
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 |
---|---|---|
@@ -1,26 +1,31 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<script src="../../resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description('Tests that we find controls if they have a range limitation and are out-of-range.'); | ||
|
||
var parentDiv = document.createElement('div'); | ||
document.body.appendChild(parentDiv); | ||
parentDiv.innerHTML = '<input id="number1" type="number" min=0 max=10 value=50><input id="text1" type="text" min=0 max=10 value=50><input id="checkbox1" type="checkbox"><input id="radio1" type="radio">'; | ||
parentDiv.innerHTML = '<input id="number1" type="number" min=0 max=10><input id="text1" type="text" min=0 max=10 value=50><input id="checkbox1" type="checkbox"><input id="radio1" type="radio">'; | ||
|
||
debug('==> :out-of-range doesn\'t match to an INPUT without a value:'); | ||
shouldBeNull('document.querySelector("input[type=number]:out-of-range")'); | ||
|
||
debug(''); | ||
debug('==> :out-of-range should match to an INPUT with an out-of-range value:'); | ||
parentDiv.firstChild.value = '50'; | ||
shouldBe('document.querySelector("input[type=number]:out-of-range").id', '"number1"'); | ||
shouldBe('document.querySelectorAll(":out-of-range").length', '1'); | ||
|
||
debug(""); | ||
debug("When the value becomes in-range dynamically, we do not find the control anymore"); | ||
debug(''); | ||
debug('==> When the value becomes in-range dynamically, we do not find the control anymore:'); | ||
document.getElementById("number1").value = 5; | ||
|
||
shouldBe('document.querySelector("input[type=number]:out-of-range")', 'null'); | ||
shouldBe('document.querySelectorAll(":out-of-range").length', '0'); | ||
</script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</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