Repository: LadybirdBrowser/ladybird
File: Libraries/LibWeb/DOM/Element.cpp (C++)

Code before:
            for (auto& new_class : new_classes) {
                m_classes.unchecked_append(FlyString::from_utf8(new_class).release_value_but_fixme_should_propagate_errors());
            }
        }
        if (m_class_list)
            m_class_list->associated_attribute_changed(value_or_empty);
    } else if (local_name == HTML::AttributeNames::style) {
        // https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-updating-flag
        if (m_inline_style && m_inline_style->is_updating())
            return;
        if (!m_inline_style)
            m_inline_style = CSS::CSSStyleProperties::create_element_inline_style({ *this }, {}, {});
        m_inline_style->set_declarations_from_text(value.value_or(""_string));
        set_needs_style_update(true);
    } else if (local_name == HTML::AttributeNames::dir) {
        // https://html.spec.whatwg.org/multipage/dom.html#attr-dir
        if (value_or_empty.equals_ignoring_ascii_case("ltr"sv))
            m_dir = Dir::Ltr;
        else if (value_or_empty.equals_ignoring_ascii_case("rtl"sv))
            m_dir = Dir::Rtl;
        else if (value_or_empty.equals_ignoring_ascii_case("auto"sv))
            m_dir = Dir::Auto;
        else
            m_dir = {};
    } else if (local_name == HTML::AttributeNames::lang) {
        invalidate_lang_value();
        for_each_in_inclusive_subtree_of_type<Element>([](auto& element) {
            element.invalidate_lang_value();
            return TraversalDecision::Continue;
        });
    }

    // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:concept-element-attributes-change-ext
    // 1. If localName is not attr or namespace is not null, then return.
    // 2. Set element's explicitly set attr-element to null.
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute)                               \
    else if (local_name == ARIA::AttributeNames::referencing_attribute && !namespace_.has_value()) \
    {                                                                                              \
        set_##attribute({});                                                                       \
    }
    ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES
#undef __ENUMERATE_ARIA_ATTRIBUTE

    // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:concept-element-attributes-change-ext-2
    // 1. If localName is not attr or namespace is not null, then return.
    // 2. Set element's explicitly set attr-elements to null.
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute)                               \
    else if (local_name == ARIA::AttributeNames::referencing_attribute && !namespace_.has_value()) \
    {                                                                                              \
        set_##attribute({});                                                                       \
    }

Review comment (suggestion):
Since you use `for_each_in_inclusive_subtree_of_type()` below, you can drop this line.

Code after:
            for (auto& new_class : new_classes) {
                m_classes.unchecked_append(FlyString::from_utf8(new_class).release_value_but_fixme_should_propagate_errors());
            }
        }
        if (m_class_list)
            m_class_list->associated_attribute_changed(value_or_empty);
    } else if (local_name == HTML::AttributeNames::style) {
        // https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-updating-flag
        if (m_inline_style && m_inline_style->is_updating())
            return;
        if (!m_inline_style)
            m_inline_style = CSS::CSSStyleProperties::create_element_inline_style({ *this }, {}, {});
        m_inline_style->set_declarations_from_text(value.value_or(""_string));
        set_needs_style_update(true);
    } else if (local_name == HTML::AttributeNames::dir) {
        // https://html.spec.whatwg.org/multipage/dom.html#attr-dir
        if (value_or_empty.equals_ignoring_ascii_case("ltr"sv))
            m_dir = Dir::Ltr;
        else if (value_or_empty.equals_ignoring_ascii_case("rtl"sv))
            m_dir = Dir::Rtl;
        else if (value_or_empty.equals_ignoring_ascii_case("auto"sv))
            m_dir = Dir::Auto;
        else
            m_dir = {};
    } else if (local_name == HTML::AttributeNames::lang) {
        for_each_in_inclusive_subtree_of_type<Element>([](auto& element) {
            element.invalidate_lang_value();
            return TraversalDecision::Continue;
        });
    }

    // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:concept-element-attributes-change-ext
    // 1. If localName is not attr or namespace is not null, then return.
    // 2. Set element's explicitly set attr-element to null.
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute)                               \
    else if (local_name == ARIA::AttributeNames::referencing_attribute && !namespace_.has_value()) \
    {                                                                                              \
        set_##attribute({});                                                                       \
    }
    ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES
#undef __ENUMERATE_ARIA_ATTRIBUTE

    // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:concept-element-attributes-change-ext-2
    // 1. If localName is not attr or namespace is not null, then return.
    // 2. Set element's explicitly set attr-elements to null.
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute)                               \
    else if (local_name == ARIA::AttributeNames::referencing_attribute && !namespace_.has_value()) \
    {                                                                                              \
        set_##attribute({});                                                                       \
    }
    ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES