mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1556363 - Part 2: Support disabled attribute for form-associated custom element; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D129049
This commit is contained in:
parent
36107cfddf
commit
606cf9d3e9
@ -39,6 +39,7 @@ JSObject* HTMLElement::WrapNode(JSContext* aCx,
|
||||
|
||||
void HTMLElement::SetCustomElementDefinition(
|
||||
CustomElementDefinition* aDefinition) {
|
||||
nsGenericHTMLFormElement::SetCustomElementDefinition(aDefinition);
|
||||
// Always create an ElementInternal for form-associated custom element as the
|
||||
// Form related implementation lives in ElementInternal which implements
|
||||
// nsIFormControl. It is okay for the attachElementInternal API as there is a
|
||||
@ -48,8 +49,14 @@ void HTMLElement::SetCustomElementDefinition(
|
||||
CustomElementData* data = GetCustomElementData();
|
||||
MOZ_ASSERT(data);
|
||||
data->GetOrCreateElementInternals(this);
|
||||
|
||||
// This is for the case that script constructs a custom element directly,
|
||||
// e.g. via new MyCustomElement(), where the upgrade steps won't be ran to
|
||||
// update the disabled state in UpdateFormOwner().
|
||||
if (data->mState == CustomElementData::State::eCustom) {
|
||||
UpdateDisabledState(true);
|
||||
}
|
||||
}
|
||||
nsGenericHTMLFormElement::SetCustomElementDefinition(aDefinition);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/commit-snapshots/53bc3803433e1c817918b83e8a84f3db900031dd/#dom-attachinternals
|
||||
@ -143,6 +150,20 @@ void HTMLElement::UpdateFormOwner() {
|
||||
nsGenericHTMLFormElement::UpdateFormOwner(true, nullptr);
|
||||
}
|
||||
UpdateFieldSet(true);
|
||||
UpdateDisabledState(true);
|
||||
}
|
||||
|
||||
nsresult HTMLElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
||||
const nsAttrValue* aValue,
|
||||
const nsAttrValue* aOldValue,
|
||||
nsIPrincipal* aMaybeScriptedPrincipal,
|
||||
bool aNotify) {
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled) {
|
||||
UpdateDisabledState(aNotify);
|
||||
}
|
||||
|
||||
return nsGenericHTMLFormElement::AfterSetAttr(
|
||||
aNameSpaceID, aName, aValue, aOldValue, aMaybeScriptedPrincipal, aNotify);
|
||||
}
|
||||
|
||||
void HTMLElement::SetFormInternal(HTMLFormElement* aForm, bool aBindToTree) {
|
||||
|
@ -44,6 +44,12 @@ class HTMLElement final : public nsGenericHTMLFormElement {
|
||||
JSObject* WrapNode(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// Element
|
||||
nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
||||
const nsAttrValue* aValue, const nsAttrValue* aOldValue,
|
||||
nsIPrincipal* aMaybeScriptedPrincipal,
|
||||
bool aNotify) override;
|
||||
|
||||
// nsGenericHTMLFormElement
|
||||
void SetFormInternal(HTMLFormElement* aForm, bool aBindToTree) override;
|
||||
HTMLFormElement* GetFormInternal() const override;
|
||||
|
@ -2,17 +2,8 @@
|
||||
[Upgrading an element with disabled content attribute]
|
||||
expected: FAIL
|
||||
|
||||
[Disabled attribute affects focus-capability]
|
||||
expected: FAIL
|
||||
|
||||
[Relationship with FIELDSET]
|
||||
expected: FAIL
|
||||
|
||||
[A disabled form-associated custom element should not provide an entry for it]
|
||||
expected: FAIL
|
||||
|
||||
[A disabled form-associated custom element should not submit an entry for it]
|
||||
expected: FAIL
|
||||
|
||||
[Adding/removing disabled content attribute]
|
||||
expected: FAIL
|
||||
|
Loading…
Reference in New Issue
Block a user