mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 13:02:09 +02:00
LibWeb: Implement :enabled and :disabled pseudo classes to spec
Previously we only considered an element disabled if it was an <input> element with the disabled attribute, but there's way more elements that apply with more nuanced disabled/enabled rules.
This commit is contained in:
committed by
Andreas Kling
parent
c85fcd442f
commit
2133b7d58a
Notes:
sideshowbarker
2024-07-17 06:32:16 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/2133b7d58a Pull-request: https://github.com/SerenityOS/serenity/pull/15393
@@ -8,6 +8,7 @@
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/HTML/HTMLOptGroupElement.h>
|
||||
#include <LibWeb/HTML/HTMLOptionElement.h>
|
||||
#include <LibWeb/HTML/HTMLScriptElement.h>
|
||||
#include <LibWeb/HTML/HTMLSelectElement.h>
|
||||
@@ -156,4 +157,12 @@ void HTMLOptionElement::ask_for_a_reset()
|
||||
// FIXME: Implement this operation.
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-disabled
|
||||
bool HTMLOptionElement::disabled() const
|
||||
{
|
||||
// An option element is disabled if its disabled attribute is present or if it is a child of an optgroup element whose disabled attribute is present.
|
||||
return has_attribute(AttributeNames::disabled)
|
||||
|| (parent() && is<HTMLOptGroupElement>(parent()) && static_cast<HTMLOptGroupElement const&>(*parent()).has_attribute(AttributeNames::disabled));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user