diff --git a/src/browser/tests/element/disabled_inheritance.html b/src/browser/tests/element/disabled_inheritance.html new file mode 100644 index 00000000..e7857dfa --- /dev/null +++ b/src/browser/tests/element/disabled_inheritance.html @@ -0,0 +1,129 @@ + + + +
+
+ + + + + +
+ +
+ + +
+ + + + + + + +
+ +
x
+
y
+z + + + + + + + + + + + + diff --git a/src/browser/webapi/Element.zig b/src/browser/webapi/Element.zig index 4729711f..b6983727 100644 --- a/src/browser/webapi/Element.zig +++ b/src/browser/webapi/Element.zig @@ -600,11 +600,42 @@ pub fn hasAttributeSafe(self: *const Element, name: String) bool { return attributes.hasSafe(name); } +// Per HTML "concept-fe-disabled", only listed elements participate in the +// disabled concept. Anything else (e.g.
) has no disabled +// state and never matches :disabled / :enabled. +pub fn hasDisabledConcept(self: *const Element) bool { + return switch (self.getTag()) { + .button, .input, .select, .textarea, .optgroup, .option, .fieldset => true, + else => false, + }; +} + pub fn isDisabled(self: *Element) bool { + if (!self.hasDisabledConcept()) { + return false; + } + if (self.getAttributeSafe(comptime .wrap("disabled")) != null) { return true; } + // . It does NOT inherit from