File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -535,9 +535,7 @@ up.Params = class Params {
535535
536536 // Fields and buttons that a preview disabled still count, e.g. for a second submission
537537 // while the first one is loading.
538- let disableAgain = up . form . enablePreviewDisabledTemp ( form )
539-
540- try {
538+ return up . form . withPreviewFieldsEnabled ( form , ( ) => {
541539 // We let the browser serialize the form, instead of iterating over up.form.fields():
542540 //
543541 // - Only the browser can read the value of a form-associated custom element. The element
@@ -563,9 +561,7 @@ up.Params = class Params {
563561 if ( ! browserControls . has ( field ) && ! field . closest ( 'fieldset:disabled' ) ) params . addField ( field )
564562 }
565563 return params
566- } finally {
567- disableAgain ( )
568- }
564+ } )
569565 }
570566
571567 static fromContainer ( container , options ) {
Original file line number Diff line number Diff line change @@ -670,11 +670,17 @@ up.form = (function() {
670670 }
671671 }
672672
673- // Re-enables the controls that a preview has disabled, e.g. to read their params.
674- // Returns a function that disables them again.
675- function enablePreviewDisabledTemp ( form ) {
673+ // Runs the given function while the controls that a preview has disabled are enabled,
674+ // e.g. to read their params. Disables them again afterwards .
675+ function withPreviewFieldsEnabled ( form , fn ) {
676676 let controls = findFieldsAndButtons ( form ) . filter ( ( control ) => control . upPreviewDisabled && readFieldDisabled ( control ) )
677- return u . sequence ( u . map ( controls , ( control ) => writeFieldDisabled ( control , false ) ) )
677+ let disableAgain = u . sequence ( u . map ( controls , ( control ) => writeFieldDisabled ( control , false ) ) )
678+
679+ try {
680+ return fn ( )
681+ } finally {
682+ disableAgain ( )
683+ }
678684 }
679685
680686 function setContainerDisabled ( container , disabled ) {
@@ -2455,7 +2461,7 @@ up.form = (function() {
24552461 focusedField,
24562462 // disableWhile,
24572463 disableTemp : disableContainerTemp ,
2458- enablePreviewDisabledTemp ,
2464+ withPreviewFieldsEnabled ,
24592465 setDisabled : setContainerDisabled ,
24602466 getDisablePreviewFn,
24612467 // handleDisableOption,
You can’t perform that action at this time.
0 commit comments