File tree Expand file tree Collapse file tree 3 files changed +2
-54
lines changed Expand file tree Collapse file tree 3 files changed +2
-54
lines changed Original file line number Diff line number Diff line change @@ -29,19 +29,14 @@ export const FormRegisteringMixin = dedupeMixin(
2929
3030 __setupRegistrationHook ( ) {
3131 if ( formRegistrarManager . ready ) {
32- this . _registerFormElement ( ) ;
32+ this . _dispatchRegistration ( ) ;
3333 } else {
3434 formRegistrarManager . addEventListener ( 'all-forms-open-for-registration' , ( ) => {
35- this . _registerFormElement ( ) ;
35+ this . _dispatchRegistration ( ) ;
3636 } ) ;
3737 }
3838 }
3939
40- _registerFormElement ( ) {
41- this . _dispatchRegistration ( ) ;
42- this . _requestParentFormGroupUpdateOfResetModelValue ( ) ;
43- }
44-
4540 _dispatchRegistration ( ) {
4641 this . dispatchEvent (
4742 new CustomEvent ( 'form-element-register' , {
@@ -56,16 +51,5 @@ export const FormRegisteringMixin = dedupeMixin(
5651 this . __parentFormGroup . removeFormElement ( this ) ;
5752 }
5853 }
59-
60- /**
61- * Makes sure our parentFormGroup has the most up to date resetModelValue
62- * FormGroups will call the same on their parentFormGroup so the full tree gets the correct
63- * values.
64- */
65- _requestParentFormGroupUpdateOfResetModelValue ( ) {
66- if ( this . __parentFormGroup && this . __parentFormGroup . _updateResetModelValue ) {
67- this . __parentFormGroup . _updateResetModelValue ( ) ;
68- }
69- }
7054 } ,
7155) ;
Original file line number Diff line number Diff line change @@ -122,14 +122,6 @@ export class LionField extends FormControlMixin(
122122
123123 disconnectedCallback ( ) {
124124 super . disconnectedCallback ( ) ;
125-
126- if ( this . __parentFormGroup ) {
127- const event = new CustomEvent ( 'form-element-unregister' , {
128- detail : { element : this } ,
129- bubbles : true ,
130- } ) ;
131- this . __parentFormGroup . dispatchEvent ( event ) ;
132- }
133125 this . inputElement . removeEventListener ( 'change' , this . _onChange ) ;
134126 }
135127
Original file line number Diff line number Diff line change @@ -117,33 +117,5 @@ export const runRegistrationSuite = customConfig => {
117117 el . removeChild ( newField ) ;
118118 expect ( el . formElements . length ) . to . equal ( 1 ) ;
119119 } ) ;
120-
121- describe ( 'Unregister' , ( ) => {
122- it . skip ( 'requests update of the resetModelValue function of its parent formGroup on unregister' , async ( ) => {
123- const ParentFormGroupClass = class extends FormRegistrarMixin ( LitElement ) {
124- _updateResetModelValue ( ) {
125- this . resetModelValue = this . formElements . length ;
126- }
127- } ;
128- const ChildFormGroupClass = class extends FormRegisteringMixin ( LitElement ) {
129- constructor ( ) {
130- super ( ) ;
131- this . __parentFormGroup = this . parentNode ;
132- }
133- } ;
134-
135- const formGroupTag = unsafeStatic ( defineCE ( ParentFormGroupClass ) ) ;
136- const childFormGroupTag = unsafeStatic ( defineCE ( ChildFormGroupClass ) ) ;
137- const parentFormEl = await fixture ( html `
138- < ${ formGroupTag } >
139- < ${ childFormGroupTag } name="child[]"> </ ${ childFormGroupTag } >
140- < ${ childFormGroupTag } name="child[]"> </ ${ childFormGroupTag } >
141- </ ${ formGroupTag } >
142- ` ) ;
143- expect ( parentFormEl . resetModelValue . length ) . to . equal ( 2 ) ;
144- parentFormEl . removeChild ( parentFormEl . children [ 0 ] ) ;
145- expect ( parentFormEl . resetModelValue . length ) . to . equal ( 1 ) ;
146- } ) ;
147- } ) ;
148120 } ) ;
149121} ;
You can’t perform that action at this time.
0 commit comments