Fix element.hidden IDL case sensitivity
The element.hidden IDL was reflecting as "until-found" only if the actual value in the attribute was all lowercase due to a missing case insensitivity check. This patch fixes this by making the comparison case insensitive. I also moved the "until-found" string to keywords. Fixed: 402108887 Change-Id: I6da84f612906742adc49e77b4cfbeedd7d300b21 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6338281 Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1431623}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
47fb6f0342
commit
d978d40415
third_party/blink
renderer
core
web_tests
external
wpt
html
editing
the-hidden-attribute
@@ -835,7 +835,7 @@ bool DisplayLockUtilities::RevealHiddenUntilFoundAncestors(const Node& node) {
|
|||||||
if (HTMLElement* element = DynamicTo<HTMLElement>(parent)) {
|
if (HTMLElement* element = DynamicTo<HTMLElement>(parent)) {
|
||||||
if (EqualIgnoringASCIICase(
|
if (EqualIgnoringASCIICase(
|
||||||
element->FastGetAttribute(html_names::kHiddenAttr),
|
element->FastGetAttribute(html_names::kHiddenAttr),
|
||||||
"until-found")) {
|
keywords::kUntilFound)) {
|
||||||
elements_to_reveal.push_back(element);
|
elements_to_reveal.push_back(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3108,7 +3108,7 @@ void Element::AttributeChanged(const AttributeModificationParams& params) {
|
|||||||
StyleAttributeChanged(params.new_value, params.reason);
|
StyleAttributeChanged(params.new_value, params.reason);
|
||||||
} else if (IsPresentationAttribute(name)) {
|
} else if (IsPresentationAttribute(name)) {
|
||||||
if (name == html_names::kHiddenAttr) {
|
if (name == html_names::kHiddenAttr) {
|
||||||
if (params.new_value == "until-found") {
|
if (params.new_value == keywords::kUntilFound) {
|
||||||
EnsureDisplayLockContext().SetIsHiddenUntilFoundElement(true);
|
EnsureDisplayLockContext().SetIsHiddenUntilFoundElement(true);
|
||||||
} else if (DisplayLockContext* context = GetDisplayLockContext()) {
|
} else if (DisplayLockContext* context = GetDisplayLockContext()) {
|
||||||
context->SetIsHiddenUntilFoundElement(false);
|
context->SetIsHiddenUntilFoundElement(false);
|
||||||
|
@@ -368,7 +368,7 @@ void HTMLElement::CollectStyleForPresentationAttribute(
|
|||||||
style, CSSPropertyID::kWebkitUserModify, CSSValueID::kReadOnly);
|
style, CSSPropertyID::kWebkitUserModify, CSSValueID::kReadOnly);
|
||||||
}
|
}
|
||||||
} else if (name == html_names::kHiddenAttr) {
|
} else if (name == html_names::kHiddenAttr) {
|
||||||
if (EqualIgnoringASCIICase(value, "until-found")) {
|
if (EqualIgnoringASCIICase(value, keywords::kUntilFound)) {
|
||||||
AddPropertyToPresentationAttributeStyle(
|
AddPropertyToPresentationAttributeStyle(
|
||||||
style, CSSPropertyID::kContentVisibility, CSSValueID::kHidden);
|
style, CSSPropertyID::kContentVisibility, CSSValueID::kHidden);
|
||||||
UseCounter::Count(GetDocument(), WebFeature::kHiddenUntilFoundAttribute);
|
UseCounter::Count(GetDocument(), WebFeature::kHiddenUntilFoundAttribute);
|
||||||
@@ -1150,9 +1150,9 @@ V8UnionBooleanOrStringOrUnrestrictedDouble* HTMLElement::hidden() const {
|
|||||||
return MakeGarbageCollected<V8UnionBooleanOrStringOrUnrestrictedDouble>(
|
return MakeGarbageCollected<V8UnionBooleanOrStringOrUnrestrictedDouble>(
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
if (attribute == "until-found") {
|
if (EqualIgnoringASCIICase(attribute, keywords::kUntilFound)) {
|
||||||
return MakeGarbageCollected<V8UnionBooleanOrStringOrUnrestrictedDouble>(
|
return MakeGarbageCollected<V8UnionBooleanOrStringOrUnrestrictedDouble>(
|
||||||
String("until-found"));
|
String(keywords::kUntilFound));
|
||||||
}
|
}
|
||||||
return MakeGarbageCollected<V8UnionBooleanOrStringOrUnrestrictedDouble>(true);
|
return MakeGarbageCollected<V8UnionBooleanOrStringOrUnrestrictedDouble>(true);
|
||||||
}
|
}
|
||||||
@@ -1172,8 +1172,9 @@ void HTMLElement::setHidden(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case V8UnionBooleanOrStringOrUnrestrictedDouble::ContentType::kString:
|
case V8UnionBooleanOrStringOrUnrestrictedDouble::ContentType::kString:
|
||||||
if (EqualIgnoringASCIICase(value->GetAsString(), "until-found")) {
|
if (EqualIgnoringASCIICase(value->GetAsString(), keywords::kUntilFound)) {
|
||||||
setAttribute(html_names::kHiddenAttr, AtomicString("until-found"));
|
setAttribute(html_names::kHiddenAttr,
|
||||||
|
AtomicString(keywords::kUntilFound));
|
||||||
} else if (value->GetAsString() == "") {
|
} else if (value->GetAsString() == "") {
|
||||||
removeAttribute(html_names::kHiddenAttr);
|
removeAttribute(html_names::kHiddenAttr);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -117,6 +117,10 @@
|
|||||||
"show",
|
"show",
|
||||||
"hide",
|
"hide",
|
||||||
|
|
||||||
|
// hidden=until-found attribute
|
||||||
|
// https://html.spec.whatwg.org/#the-hidden-attribute
|
||||||
|
"until-found",
|
||||||
|
|
||||||
// dialog closedby attribute
|
// dialog closedby attribute
|
||||||
// See https://github.com/whatwg/html/pull/10737.
|
// See https://github.com/whatwg/html/pull/10737.
|
||||||
"any",
|
"any",
|
||||||
|
20
third_party/blink/web_tests/external/wpt/html/editing/the-hidden-attribute/hidden-until-found-idl.html
vendored
Normal file
20
third_party/blink/web_tests/external/wpt/html/editing/the-hidden-attribute/hidden-until-found-idl.html
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<link rel=author href="mailto:jarhar@chromium.org">
|
||||||
|
<link rel=help href="https://html.spec.whatwg.org/#the-hidden-attribute">
|
||||||
|
<link rel=helph href="https://issues.chromium.org/issues/402108887">
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
|
||||||
|
<div id=target>div</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const target = document.getElementById('target');
|
||||||
|
target.setAttribute('hidden', 'UNTIL-FOUND');
|
||||||
|
assert_equals(target.hidden, 'until-found');
|
||||||
|
target.setAttribute('hidden', 'uNtIl-FoUnD');
|
||||||
|
assert_equals(target.hidden, 'until-found');
|
||||||
|
target.setAttribute('hidden', 'until-found');
|
||||||
|
assert_equals(target.hidden, 'until-found');
|
||||||
|
}, 'element.hidden should return "until-found" regardless of uppercase letters.');
|
||||||
|
</script>
|
Reference in New Issue
Block a user