Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing handler in affected_by_invalidation_property() #3365

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Libraries/LibWeb/CSS/StyleInvalidationData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ static void collect_properties_used_in_has(Selector::SimpleSelector const& selec
case PseudoClass::Disabled:
case PseudoClass::PlaceholderShown:
case PseudoClass::Checked:
style_invalidation_data.pseudo_classes_used_in_has_selectors.set(pseudo_class.type);
if (in_has)
style_invalidation_data.pseudo_classes_used_in_has_selectors.set(pseudo_class.type);
kalenikaliaksandr marked this conversation as resolved.
Show resolved Hide resolved
break;
default:
break;
Expand Down
8 changes: 8 additions & 0 deletions Libraries/LibWeb/DOM/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,14 @@ bool Element::affected_by_invalidation_property(CSS::InvalidationSet::Property c
// FIXME: This could be narrowed down to return true only if element is actually checked.
return is<HTML::HTMLInputElement>(*this) || is<HTML::HTMLOptionElement>(*this);
}
case CSS::PseudoClass::PlaceholderShown: {
if (is<HTML::HTMLInputElement>(*this) && has_attribute(HTML::AttributeNames::placeholder)) {
auto const& input_element = static_cast<HTML::HTMLInputElement const&>(*this);
return input_element.placeholder_element() && input_element.placeholder_value().has_value();
}
// - FIXME: textarea elements that have a placeholder attribute whose value is currently being presented to the user.
return false;
}
default:
VERIFY_NOT_REACHED();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PASS (didn't crash)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>

<head>
<script src="include.js"></script>
<style>
#b input:placeholder-shown {
border: 2px dashed red;
background-color: #ffecec;
}
</style>
</head>

<body>
<div id="a"><input type="text" placeholder=""></input></div>
<script>
test(() => {
document.documentElement.offsetHeight; // force style recalculation
const a = document.getElementById('a');
a.id = 'b';
println("PASS (didn't crash)");
});
</script>
</body>

</html>
Loading