mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibWeb: Correctly handle serialization of PseudoElements
Previusly the implementation only was serializing PseudoElements if they were the last element in the CompoundSelector. This caused bugs on Javascript code that referenced their selectorText, where it would be wrong.
This commit is contained in:
parent
b85a8a23a7
commit
da14e072b7
Notes:
github-actions[bot]
2025-06-24 11:46:10 +00:00
Author: https://github.com/luizgfranca 🔰
Commit: da14e072b7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5174
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 23 additions and 4 deletions
|
@ -475,7 +475,8 @@ String Selector::SimpleSelector::serialize() const
|
|||
break;
|
||||
}
|
||||
case Selector::SimpleSelector::Type::PseudoElement:
|
||||
// Note: Pseudo-elements are dealt with in Selector::serialize()
|
||||
// AD-HOC: Spec issue: https://github.com/w3c/csswg-drafts/issues/11997
|
||||
s.append(this->pseudo_element().serialize());
|
||||
break;
|
||||
case Type::Nesting:
|
||||
// AD-HOC: Not in spec yet.
|
||||
|
@ -572,9 +573,8 @@ String Selector::serialize() const
|
|||
} else {
|
||||
// 4. If this is the last part of the chain of the selector and there is a pseudo-element,
|
||||
// append "::" followed by the name of the pseudo-element, to s.
|
||||
if (compound_selector.simple_selectors.last().type == Selector::SimpleSelector::Type::PseudoElement) {
|
||||
s.append(compound_selector.simple_selectors.last().pseudo_element().serialize());
|
||||
}
|
||||
// This algorithm has a problem, see https://github.com/w3c/csswg-drafts/issues/11997
|
||||
// serialization of pseudoElements was moved to SimpleSelector::serialize()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
::-webkit-scrollbar-thumb
|
||||
::-webkit-scrollbar-thumb:hover
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #28bea5;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #28bea5;
|
||||
}
|
||||
</style>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
for (let rule of document.styleSheets[0].cssRules) {
|
||||
println(rule.selectorText);
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue