Bug 1708702 - Add to radio group after handling type change r=edgar
The previous assumption was that mType would be updated before AfterSetAttr(), but that assumption is invalidated by bug 1347640. This patch moves the radio group addition part to the position after HandleTypeChange() is called. Differential Revision: https://phabricator.services.mozilla.com/D114038
This commit is contained in:
@@ -1136,24 +1136,25 @@ nsresult HTMLInputElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
bool aNotify) {
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
//
|
||||
// When name or type changes, radio should be removed from radio group.
|
||||
// (type changes are handled in the form itself currently)
|
||||
// If we are not done creating the radio, we also should not do it.
|
||||
//
|
||||
if ((aName == nsGkAtoms::name || (aName == nsGkAtoms::type && !mForm)) &&
|
||||
mType == NS_FORM_INPUT_RADIO && (mForm || mDoneCreating)) {
|
||||
WillRemoveFromRadioGroup();
|
||||
} else if (aNotify && aName == nsGkAtoms::disabled) {
|
||||
if (aNotify && aName == nsGkAtoms::disabled) {
|
||||
mDisabledChanged = true;
|
||||
} else if (mType == NS_FORM_INPUT_RADIO && aName == nsGkAtoms::required) {
|
||||
nsCOMPtr<nsIRadioGroupContainer> container = GetRadioGroupContainer();
|
||||
}
|
||||
|
||||
if (container && ((aValue && !HasAttr(aNameSpaceID, aName)) ||
|
||||
(!aValue && HasAttr(aNameSpaceID, aName)))) {
|
||||
nsAutoString name;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||
container->RadioRequiredWillChange(name, !!aValue);
|
||||
// When name or type changes, radio should be removed from radio group.
|
||||
// If we are not done creating the radio, we also should not do it.
|
||||
if (mType == NS_FORM_INPUT_RADIO) {
|
||||
if ((aName == nsGkAtoms::name || (aName == nsGkAtoms::type && !mForm)) &&
|
||||
(mForm || mDoneCreating)) {
|
||||
WillRemoveFromRadioGroup();
|
||||
} else if (aName == nsGkAtoms::required) {
|
||||
nsCOMPtr<nsIRadioGroupContainer> container = GetRadioGroupContainer();
|
||||
|
||||
if (container && ((aValue && !HasAttr(aNameSpaceID, aName)) ||
|
||||
(!aValue && HasAttr(aNameSpaceID, aName)))) {
|
||||
nsAutoString name;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||
container->RadioRequiredWillChange(name, !!aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1172,17 +1173,6 @@ nsresult HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
||||
nsIPrincipal* aSubjectPrincipal,
|
||||
bool aNotify) {
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
//
|
||||
// When name or type changes, radio should be added to radio group.
|
||||
// (type changes are handled in the form itself currently)
|
||||
// If we are not done creating the radio, we also should not do it.
|
||||
//
|
||||
if ((aName == nsGkAtoms::name || (aName == nsGkAtoms::type && !mForm)) &&
|
||||
mType == NS_FORM_INPUT_RADIO && (mForm || mDoneCreating)) {
|
||||
AddedToRadioGroup();
|
||||
UpdateValueMissingValidityStateForRadio(false);
|
||||
}
|
||||
|
||||
if (aName == nsGkAtoms::src) {
|
||||
mSrcTriggeringPrincipal = nsContentUtils::GetAttrTriggeringPrincipal(
|
||||
this, aValue ? aValue->GetStringValue() : EmptyString(),
|
||||
@@ -1241,6 +1231,14 @@ nsresult HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
||||
}
|
||||
}
|
||||
|
||||
// When name or type changes, radio should be added to radio group.
|
||||
// If we are not done creating the radio, we also should not do it.
|
||||
if ((aName == nsGkAtoms::name || (aName == nsGkAtoms::type && !mForm)) &&
|
||||
mType == NS_FORM_INPUT_RADIO && (mForm || mDoneCreating)) {
|
||||
AddedToRadioGroup();
|
||||
UpdateValueMissingValidityStateForRadio(false);
|
||||
}
|
||||
|
||||
if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled ||
|
||||
aName == nsGkAtoms::readonly) {
|
||||
if (aName == nsGkAtoms::disabled) {
|
||||
|
||||
Reference in New Issue
Block a user