Bug 1737364 - Part 2: Elements should be barred from constraint validation if it has a datalist element ancestor; r=smaug

Add a new flag, ELEMENT_IS_DATALIST_OR_HAS_DATALIST_ANCESTOR, to indicate that
the element is a HTML datalist element or has a HTML datalist element ancestor.

Per https://html.spec.whatwg.org/multipage/form-elements.html#the-datalist-element:barred-from-constraint-validation

Differential Revision: https://phabricator.services.mozilla.com/D129717
This commit is contained in:
Edgar Chen
2021-11-03 20:07:43 +00:00
parent b6ba0994c5
commit 5098930d81
11 changed files with 108 additions and 22 deletions

View File

@@ -6583,7 +6583,8 @@ void HTMLInputElement::UpdateBarredFromConstraintValidation() {
mType == FormControlType::InputHidden ||
mType == FormControlType::InputButton ||
mType == FormControlType::InputReset ||
HasAttr(kNameSpaceID_None, nsGkAtoms::readonly) || IsDisabled());
HasAttr(kNameSpaceID_None, nsGkAtoms::readonly) ||
HasFlag(ELEMENT_IS_DATALIST_OR_HAS_DATALIST_ANCESTOR) || IsDisabled());
}
nsresult HTMLInputElement::GetValidationMessage(nsAString& aValidationMessage,