mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
LibWeb: Implement the attribute-change-steps extension
This is similar to the run activation behavior in that elements may define these steps themselves. HTMLSlotElement is one such element. The existing (ad-hoc) Element::attribute_changed() method is not sufficient there as the steps require knowledge of the attribute's old value and its namespace, which this extension provides. Unlike the run activation behavior, we store these steps in a list. An element may end up defining multiple attribute change steps. For example all DOM elements must define steps to handle the "slot" attribute, and HTMLSlotElement must define steps to handle the "name" attribute.
This commit is contained in:
parent
54b5a431a3
commit
b85a252753
2 changed files with 13 additions and 3 deletions
|
@ -409,10 +409,15 @@ CSS::CSSStyleDeclaration const* Element::inline_style() const
|
|||
return m_inline_style.ptr();
|
||||
}
|
||||
|
||||
void Element::run_attribute_change_steps(DeprecatedFlyString const& local_name, DeprecatedString const&, DeprecatedString const& value, DeprecatedFlyString const&)
|
||||
void Element::add_attribute_change_steps(AttributeChangeSteps steps)
|
||||
{
|
||||
// FIXME: Implement the element's attribute change steps:
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-change-ext
|
||||
m_attribute_change_steps.append(move(steps));
|
||||
}
|
||||
|
||||
void Element::run_attribute_change_steps(DeprecatedFlyString const& local_name, DeprecatedString const& old_value, DeprecatedString const& value, DeprecatedFlyString const& namespace_)
|
||||
{
|
||||
for (auto const& attribute_change_steps : m_attribute_change_steps)
|
||||
attribute_change_steps(local_name, old_value, value, namespace_);
|
||||
|
||||
// AD-HOC: Run our own internal attribute change handler.
|
||||
attribute_changed(local_name, value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue