Bug 1385478 - Part 1: Use IsRequired/Required() to get the current required state. r=bz
IsRequired() helper function returns the current 'required' state of the element, that is, whether its required attribute is set or not. This will be used only for input elements that @required applies.
This commit is contained in:
@@ -2314,7 +2314,10 @@ HTMLFormElement::AddToRadioGroup(const nsAString& aName,
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
|
||||
NS_ASSERTION(element, "radio controls have to be content elements!");
|
||||
|
||||
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
|
||||
HTMLInputElement* input = HTMLInputElement::FromContent(element);
|
||||
NS_ASSERTION(input, "radio controls have to be input elements!");
|
||||
|
||||
if (input->IsRequired()) {
|
||||
auto entry = mRequiredRadioButtonCounts.LookupForAdd(aName);
|
||||
if (!entry) {
|
||||
entry.OrInsert([]() { return 1; });
|
||||
@@ -2329,9 +2332,12 @@ HTMLFormElement::RemoveFromRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio)
|
||||
{
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
|
||||
NS_ASSERTION(element, "radio controls have to be content elements!");
|
||||
NS_ASSERTION(element, "radio controls have to be content elements");
|
||||
|
||||
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
|
||||
HTMLInputElement* input = HTMLInputElement::FromContent(element);
|
||||
NS_ASSERTION(input, "radio controls have to be input elements!");
|
||||
|
||||
if (input->IsRequired()) {
|
||||
auto entry = mRequiredRadioButtonCounts.Lookup(aName);
|
||||
if (!entry) {
|
||||
MOZ_ASSERT_UNREACHABLE("At least one radio button has to be required!");
|
||||
|
||||
Reference in New Issue
Block a user