@@ -318,7 +318,7 @@ const inject = {
318318 ) {
319319 _confirm = this . elementIsDirty ( cfg . $target ) ;
320320 } else if ( cfg . confirm === "class" && cfg . target && cfg . target !== "none" ) {
321- _confirm = cfg . $target . hasClass ( "is-dirty" ) ;
321+ _confirm = cfg . $target ? .hasClass ( "is-dirty" ) ;
322322 }
323323 if ( _confirm ) {
324324 should_confirm = true ;
@@ -411,8 +411,8 @@ const inject = {
411411 // Special case, we don't want to display any return value.
412412 return ;
413413 }
414- const $form = cfg . $target . parents ( "form" ) ;
415- if ( $form . length !== 0 && cfg . $target . data ( "initial-value" ) === undefined ) {
414+ const $form = cfg . $target ? .parents ( "form" ) ;
415+ if ( $form && $form . length !== 0 && cfg . $target . data ( "initial-value" ) === undefined ) {
416416 cfg . $target . data ( "initial-value" , cfg . $target . html ( ) ) ;
417417 $form . on ( "reset" , ( ) => {
418418 cfg . $target . html ( cfg . $target . data ( "initial-value" ) ) ;
@@ -455,7 +455,10 @@ const inject = {
455455 * appended to the body.
456456 */
457457 if ( selector . slice ( 0 , 1 ) !== "#" ) {
458- log . error ( "only id supported for non-existing target" ) ;
458+ log . error (
459+ "only id supported for non-existing target. selector: " ,
460+ selector
461+ ) ;
459462 return null ;
460463 }
461464 const $target = $ ( "<div />" ) . attr ( { id : selector . slice ( 1 ) } ) ;
@@ -737,7 +740,7 @@ const inject = {
737740 // Add a loading class to the target.
738741 // Can be used for loading-spinners.
739742 if ( cfg ?. loadingClass && cfg ?. target !== "none" ) {
740- cfg . $target . addClass ( cfg . loadingClass ) ;
743+ cfg . $target ? .addClass ( cfg . loadingClass ) ;
741744 }
742745 }
743746
0 commit comments