mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/CSS: Make :has()
take a <relative-selector-list>
The spec changed this at some point.
This commit is contained in:
parent
a94282e0e8
commit
ad1f93504e
Notes:
github-actions[bot]
2024-11-14 19:08:42 +00:00
Author: https://github.com/AtkinsSJ
Commit: ad1f93504e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2340
7 changed files with 40 additions and 14 deletions
|
@ -641,9 +641,13 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
|
||||||
.languages = move(languages) }
|
.languages = move(languages) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
case PseudoClassMetadata::ParameterType::RelativeSelectorList:
|
||||||
case PseudoClassMetadata::ParameterType::SelectorList: {
|
case PseudoClassMetadata::ParameterType::SelectorList: {
|
||||||
auto function_token_stream = TokenStream(pseudo_function.value);
|
auto function_token_stream = TokenStream(pseudo_function.value);
|
||||||
auto not_selector = TRY(parse_a_selector_list(function_token_stream, SelectorType::Standalone));
|
auto selector_type = metadata.parameter_type == PseudoClassMetadata::ParameterType::SelectorList
|
||||||
|
? SelectorType::Standalone
|
||||||
|
: SelectorType::Relative;
|
||||||
|
auto not_selector = TRY(parse_a_selector_list(function_token_stream, selector_type));
|
||||||
|
|
||||||
return Selector::SimpleSelector {
|
return Selector::SimpleSelector {
|
||||||
.type = Selector::SimpleSelector::Type::PseudoClass,
|
.type = Selector::SimpleSelector::Type::PseudoClass,
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
"argument": ""
|
"argument": ""
|
||||||
},
|
},
|
||||||
"has": {
|
"has": {
|
||||||
"argument": "<forgiving-relative-selector-list>"
|
"argument": "<relative-selector-list>"
|
||||||
},
|
},
|
||||||
"host": {
|
"host": {
|
||||||
"argument": "<compound-selector>?"
|
"argument": "<compound-selector>?"
|
||||||
|
|
|
@ -545,6 +545,7 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector, int in
|
||||||
case CSS::PseudoClassMetadata::ParameterType::CompoundSelector:
|
case CSS::PseudoClassMetadata::ParameterType::CompoundSelector:
|
||||||
case CSS::PseudoClassMetadata::ParameterType::ForgivingSelectorList:
|
case CSS::PseudoClassMetadata::ParameterType::ForgivingSelectorList:
|
||||||
case CSS::PseudoClassMetadata::ParameterType::ForgivingRelativeSelectorList:
|
case CSS::PseudoClassMetadata::ParameterType::ForgivingRelativeSelectorList:
|
||||||
|
case CSS::PseudoClassMetadata::ParameterType::RelativeSelectorList:
|
||||||
case CSS::PseudoClassMetadata::ParameterType::SelectorList: {
|
case CSS::PseudoClassMetadata::ParameterType::SelectorList: {
|
||||||
builder.append("([\n"sv);
|
builder.append("([\n"sv);
|
||||||
for (auto& child_selector : pseudo_class.argument_selector_list)
|
for (auto& child_selector : pseudo_class.argument_selector_list)
|
||||||
|
|
|
@ -75,6 +75,7 @@ struct PseudoClassMetadata {
|
||||||
ForgivingRelativeSelectorList,
|
ForgivingRelativeSelectorList,
|
||||||
Ident,
|
Ident,
|
||||||
LanguageRanges,
|
LanguageRanges,
|
||||||
|
RelativeSelectorList,
|
||||||
SelectorList,
|
SelectorList,
|
||||||
} parameter_type;
|
} parameter_type;
|
||||||
bool is_valid_as_function;
|
bool is_valid_as_function;
|
||||||
|
@ -174,6 +175,8 @@ PseudoClassMetadata pseudo_class_metadata(PseudoClass pseudo_class)
|
||||||
parameter_type = "Ident"_string;
|
parameter_type = "Ident"_string;
|
||||||
} else if (argument_string == "<language-ranges>"sv) {
|
} else if (argument_string == "<language-ranges>"sv) {
|
||||||
parameter_type = "LanguageRanges"_string;
|
parameter_type = "LanguageRanges"_string;
|
||||||
|
} else if (argument_string == "<relative-selector-list>"sv) {
|
||||||
|
parameter_type = "RelativeSelectorList"_string;
|
||||||
} else if (argument_string == "<selector-list>"sv) {
|
} else if (argument_string == "<selector-list>"sv) {
|
||||||
parameter_type = "SelectorList"_string;
|
parameter_type = "SelectorList"_string;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
:has(:yakthonk) should be invalid: PASS
|
|
@ -6,8 +6,8 @@ Rerun
|
||||||
|
|
||||||
Found 41 tests
|
Found 41 tests
|
||||||
|
|
||||||
31 Pass
|
37 Pass
|
||||||
10 Fail
|
4 Fail
|
||||||
Details
|
Details
|
||||||
Result Test Name MessagePass Before set checked on checkbox, testing subject
|
Result Test Name MessagePass Before set checked on checkbox, testing subject
|
||||||
Pass Set checked on checkbox, testing subject
|
Pass Set checked on checkbox, testing subject
|
||||||
|
@ -29,24 +29,24 @@ Pass Unset disabled on option, testing subject3
|
||||||
Pass Before set disabled on optgroup, testing subject
|
Pass Before set disabled on optgroup, testing subject
|
||||||
Pass Set disabled on optgroup, testing subject
|
Pass Set disabled on optgroup, testing subject
|
||||||
Pass Unset disabled on optgroup, testing subject
|
Pass Unset disabled on optgroup, testing subject
|
||||||
Fail Before set disabled on optgroup, testing subject2
|
Pass Before set disabled on optgroup, testing subject2
|
||||||
Pass Set disabled on optgroup, testing subject2
|
Pass Set disabled on optgroup, testing subject2
|
||||||
Fail Unset disabled on optgroup, testing subject2
|
Pass Unset disabled on optgroup, testing subject2
|
||||||
Pass Before set disabled on optgroup, testing subject3
|
Pass Before set disabled on optgroup, testing subject3
|
||||||
Pass Set disabled on optgroup, testing subject3
|
Pass Set disabled on optgroup, testing subject3
|
||||||
Pass Unset disabled on optgroup, testing subject3
|
Pass Unset disabled on optgroup, testing subject3
|
||||||
Fail Before set disabled on optgroup, testing subject4
|
Pass Before set disabled on optgroup, testing subject4
|
||||||
Pass Set disabled on optgroup, testing subject4
|
Pass Set disabled on optgroup, testing subject4
|
||||||
Fail Unset disabled on optgroup, testing subject4
|
Pass Unset disabled on optgroup, testing subject4
|
||||||
Pass Before setting value of text_input, testing subject
|
Pass Before setting value of text_input, testing subject
|
||||||
Fail Set value of text_input, testing subject
|
Fail Set value of text_input, testing subject
|
||||||
Pass Clear value of text_input, testing subject
|
Pass Clear value of text_input, testing subject
|
||||||
Fail Before setting value of text_input, testing subject2
|
Pass Before setting value of text_input, testing subject2
|
||||||
Pass Set value of text_input, testing subject2
|
Fail Set value of text_input, testing subject2
|
||||||
Fail Clear value of text_input, testing subject2
|
Pass Clear value of text_input, testing subject2
|
||||||
Pass Before setting value of text_input, testing subject3
|
Pass Before setting value of text_input, testing subject3
|
||||||
Fail Set value of text_input, testing subject3
|
Fail Set value of text_input, testing subject3
|
||||||
Pass Clear value of text_input, testing subject3
|
Pass Clear value of text_input, testing subject3
|
||||||
Fail Before setting value of text_input, testing subject4
|
Pass Before setting value of text_input, testing subject4
|
||||||
Pass Set value of text_input, testing subject4
|
Fail Set value of text_input, testing subject4
|
||||||
Fail Clear value of text_input, testing subject4
|
Pass Clear value of text_input, testing subject4
|
17
Tests/LibWeb/Text/input/css/invalid-selector-in-has.html
Normal file
17
Tests/LibWeb/Text/input/css/invalid-selector-in-has.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<style id="style"></style>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
let selectors = [
|
||||||
|
":has(:yakthonk)",
|
||||||
|
];
|
||||||
|
|
||||||
|
let style = document.getElementById("style");
|
||||||
|
|
||||||
|
for (let selector of selectors) {
|
||||||
|
style.innerText = `${selector} { color: red; }`;
|
||||||
|
println(`${selector} should be invalid: ${style.sheet.cssRules.length === 0 ? "PASS" : "FAIL"}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue