@@ -69,7 +69,6 @@ import {
69
69
enableBigIntSupport ,
70
70
enableCustomElementPropertySupport ,
71
71
enableClientRenderFallbackOnTextMismatch ,
72
- enableFormActions ,
73
72
disableIEWorkarounds ,
74
73
enableTrustedTypesIntegration ,
75
74
enableFilterEmptyStringAttributesDOM ,
@@ -498,71 +497,54 @@ function setProp(
498
497
if ( __DEV__ ) {
499
498
validateFormActionInDevelopment ( tag , key , value , props ) ;
500
499
}
501
- if ( enableFormActions ) {
502
- if ( typeof value === 'function' ) {
503
- // Set a javascript URL that doesn't do anything. We don't expect this to be invoked
504
- // because we'll preventDefault, but it can happen if a form is manually submitted or
505
- // if someone calls stopPropagation before React gets the event.
506
- // If CSP is used to block javascript: URLs that's fine too. It just won't show this
507
- // error message but the URL will be logged.
508
- domElement . setAttribute (
509
- key ,
510
- // eslint-disable-next-line no-script-url
511
- "javascript:throw new Error('" +
512
- 'A React form was unexpectedly submitted. If you called form.submit() manually, ' +
513
- "consider using form.requestSubmit() instead. If you\\'re trying to use " +
514
- 'event.stopPropagation() in a submit event handler, consider also calling ' +
515
- 'event.preventDefault().' +
516
- "')" ,
517
- ) ;
518
- break ;
519
- } else if ( typeof prevValue === 'function' ) {
520
- // When we're switching off a Server Action that was originally hydrated.
521
- // The server control these fields during SSR that are now trailing.
522
- // The regular diffing doesn't apply since we compare against the previous props.
523
- // Instead, we need to force them to be set to whatever they should be now.
524
- // This would be a lot cleaner if we did this whole fork in the per-tag approach.
525
- if ( key === 'formAction' ) {
526
- if ( tag !== 'input' ) {
527
- // Setting the name here isn't completely safe for inputs if this is switching
528
- // to become a radio button. In that case we let the tag based override take
529
- // control.
530
- setProp ( domElement , tag , 'name' , props . name , props , null ) ;
531
- }
532
- setProp (
533
- domElement ,
534
- tag ,
535
- 'formEncType' ,
536
- props . formEncType ,
537
- props ,
538
- null ,
539
- ) ;
540
- setProp (
541
- domElement ,
542
- tag ,
543
- 'formMethod' ,
544
- props . formMethod ,
545
- props ,
546
- null ,
547
- ) ;
548
- setProp (
549
- domElement ,
550
- tag ,
551
- 'formTarget' ,
552
- props . formTarget ,
553
- props ,
554
- null ,
555
- ) ;
556
- } else {
557
- setProp ( domElement , tag , 'encType' , props . encType , props , null ) ;
558
- setProp ( domElement , tag , 'method' , props . method , props , null ) ;
559
- setProp ( domElement , tag , 'target' , props . target , props , null ) ;
500
+ if ( typeof value === 'function' ) {
501
+ // Set a javascript URL that doesn't do anything. We don't expect this to be invoked
502
+ // because we'll preventDefault, but it can happen if a form is manually submitted or
503
+ // if someone calls stopPropagation before React gets the event.
504
+ // If CSP is used to block javascript: URLs that's fine too. It just won't show this
505
+ // error message but the URL will be logged.
506
+ domElement . setAttribute (
507
+ key ,
508
+ // eslint-disable-next-line no-script-url
509
+ "javascript:throw new Error('" +
510
+ 'A React form was unexpectedly submitted. If you called form.submit() manually, ' +
511
+ "consider using form.requestSubmit() instead. If you\\'re trying to use " +
512
+ 'event.stopPropagation() in a submit event handler, consider also calling ' +
513
+ 'event.preventDefault().' +
514
+ "')" ,
515
+ ) ;
516
+ break ;
517
+ } else if ( typeof prevValue === 'function' ) {
518
+ // When we're switching off a Server Action that was originally hydrated.
519
+ // The server control these fields during SSR that are now trailing.
520
+ // The regular diffing doesn't apply since we compare against the previous props.
521
+ // Instead, we need to force them to be set to whatever they should be now.
522
+ // This would be a lot cleaner if we did this whole fork in the per-tag approach.
523
+ if ( key === 'formAction' ) {
524
+ if ( tag !== 'input' ) {
525
+ // Setting the name here isn't completely safe for inputs if this is switching
526
+ // to become a radio button. In that case we let the tag based override take
527
+ // control.
528
+ setProp ( domElement , tag , 'name' , props . name , props , null ) ;
560
529
}
530
+ setProp (
531
+ domElement ,
532
+ tag ,
533
+ 'formEncType' ,
534
+ props . formEncType ,
535
+ props ,
536
+ null ,
537
+ ) ;
538
+ setProp ( domElement , tag , 'formMethod' , props . formMethod , props , null ) ;
539
+ setProp ( domElement , tag , 'formTarget' , props . formTarget , props , null ) ;
540
+ } else {
541
+ setProp ( domElement , tag , 'encType' , props . encType , props , null ) ;
542
+ setProp ( domElement , tag , 'method' , props . method , props , null ) ;
543
+ setProp ( domElement , tag , 'target' , props . target , props , null ) ;
561
544
}
562
545
}
563
546
if (
564
547
value == null ||
565
- ( ! enableFormActions && typeof value === 'function' ) ||
566
548
typeof value === 'symbol' ||
567
549
typeof value === 'boolean'
568
550
) {
@@ -2435,35 +2417,33 @@ function diffHydratedGenericElement(
2435
2417
) ;
2436
2418
continue ;
2437
2419
case 'action ':
2438
- case 'formAction ':
2439
- if ( enableFormActions ) {
2440
- const serverValue = domElement . getAttribute ( propKey ) ;
2441
- if ( typeof value === 'function' ) {
2442
- extraAttributes . delete ( propKey . toLowerCase ( ) ) ;
2443
- // The server can set these extra properties to implement actions.
2444
- // So we remove them from the extra attributes warnings.
2445
- if ( propKey === 'formAction' ) {
2446
- extraAttributes . delete ( 'name' ) ;
2447
- extraAttributes . delete ( 'formenctype' ) ;
2448
- extraAttributes . delete ( 'formmethod' ) ;
2449
- extraAttributes . delete ( 'formtarget' ) ;
2450
- } else {
2451
- extraAttributes . delete ( 'enctype' ) ;
2452
- extraAttributes . delete ( 'method' ) ;
2453
- extraAttributes . delete ( 'target' ) ;
2454
- }
2455
- // Ideally we should be able to warn if the server value was not a function
2456
- // however since the function can return any of these attributes any way it
2457
- // wants as a custom progressive enhancement, there's nothing to compare to.
2458
- // We can check if the function has the $FORM_ACTION property on the client
2459
- // and if it's not, warn, but that's an unnecessary constraint that they
2460
- // have to have the extra extension that doesn't do anything on the client.
2461
- continue ;
2462
- } else if ( serverValue === EXPECTED_FORM_ACTION_URL ) {
2463
- extraAttributes . delete ( propKey . toLowerCase ( ) ) ;
2464
- warnForPropDifference ( propKey , 'function' , value ) ;
2465
- continue ;
2420
+ case 'formAction ': {
2421
+ const serverValue = domElement . getAttribute ( propKey ) ;
2422
+ if ( typeof value === 'function' ) {
2423
+ extraAttributes . delete ( propKey . toLowerCase ( ) ) ;
2424
+ // The server can set these extra properties to implement actions.
2425
+ // So we remove them from the extra attributes warnings.
2426
+ if ( propKey === 'formAction' ) {
2427
+ extraAttributes . delete ( 'name' ) ;
2428
+ extraAttributes . delete ( 'formenctype' ) ;
2429
+ extraAttributes . delete ( 'formmethod' ) ;
2430
+ extraAttributes . delete ( 'formtarget' ) ;
2431
+ } else {
2432
+ extraAttributes . delete ( 'enctype' ) ;
2433
+ extraAttributes . delete ( 'method' ) ;
2434
+ extraAttributes . delete ( 'target' ) ;
2466
2435
}
2436
+ // Ideally we should be able to warn if the server value was not a function
2437
+ // however since the function can return any of these attributes any way it
2438
+ // wants as a custom progressive enhancement, there's nothing to compare to.
2439
+ // We can check if the function has the $FORM_ACTION property on the client
2440
+ // and if it's not, warn, but that's an unnecessary constraint that they
2441
+ // have to have the extra extension that doesn't do anything on the client.
2442
+ continue ;
2443
+ } else if ( serverValue === EXPECTED_FORM_ACTION_URL ) {
2444
+ extraAttributes . delete ( propKey . toLowerCase ( ) ) ;
2445
+ warnForPropDifference ( propKey , 'function' , value ) ;
2446
+ continue ;
2467
2447
}
2468
2448
hydrateSanitizedAttribute (
2469
2449
domElement ,
@@ -2473,6 +2453,7 @@ function diffHydratedGenericElement(
2473
2453
extraAttributes ,
2474
2454
) ;
2475
2455
continue ;
2456
+ }
2476
2457
case 'xlinkHref ':
2477
2458
hydrateSanitizedAttribute (
2478
2459
domElement ,
0 commit comments