@@ -2529,7 +2529,7 @@ function testDomRouter(
2529
2529
}
2530
2530
2531
2531
describe ( "static routes" , ( ) => {
2532
- it ( "includes search params + hash when no action is specified" , async ( ) => {
2532
+ it ( "includes search params when no action is specified" , async ( ) => {
2533
2533
let router = createTestRouter (
2534
2534
createRoutesFromElements (
2535
2535
< Route path = "/" >
@@ -2545,11 +2545,11 @@ function testDomRouter(
2545
2545
let { container } = render ( < RouterProvider router = { router } /> ) ;
2546
2546
2547
2547
expect ( container . querySelector ( "form" ) ?. getAttribute ( "action" ) ) . toBe (
2548
- "/foo/bar?a=1#hash "
2548
+ "/foo/bar?a=1"
2549
2549
) ;
2550
2550
} ) ;
2551
2551
2552
- it ( "does not include search params + hash when action='.'" , async ( ) => {
2552
+ it ( "does not include search params when action='.'" , async ( ) => {
2553
2553
let router = createTestRouter (
2554
2554
createRoutesFromElements (
2555
2555
< Route path = "/" >
@@ -2567,7 +2567,7 @@ function testDomRouter(
2567
2567
) ;
2568
2568
} ) ;
2569
2569
2570
- it ( "does not include search params + hash when action=''" , async ( ) => {
2570
+ it ( "does not include search params when action=''" , async ( ) => {
2571
2571
let router = createTestRouter (
2572
2572
createRoutesFromElements (
2573
2573
< Route path = "/" >
@@ -2587,7 +2587,7 @@ function testDomRouter(
2587
2587
} ) ;
2588
2588
2589
2589
describe ( "layout routes" , ( ) => {
2590
- it ( "includes search params + hash when no action is specified" , async ( ) => {
2590
+ it ( "includes search params when no action is specified" , async ( ) => {
2591
2591
let router = createTestRouter (
2592
2592
createRoutesFromElements (
2593
2593
< Route path = "/" >
@@ -2605,11 +2605,11 @@ function testDomRouter(
2605
2605
let { container } = render ( < RouterProvider router = { router } /> ) ;
2606
2606
2607
2607
expect ( container . querySelector ( "form" ) ?. getAttribute ( "action" ) ) . toBe (
2608
- "/foo/bar?a=1#hash "
2608
+ "/foo/bar?a=1"
2609
2609
) ;
2610
2610
} ) ;
2611
2611
2612
- it ( "does not include search params + hash when action='.'" , async ( ) => {
2612
+ it ( "does not include search params when action='.'" , async ( ) => {
2613
2613
let router = createTestRouter (
2614
2614
createRoutesFromElements (
2615
2615
< Route path = "/" >
@@ -2631,7 +2631,7 @@ function testDomRouter(
2631
2631
) ;
2632
2632
} ) ;
2633
2633
2634
- it ( "does not include search params + hash when action=''" , async ( ) => {
2634
+ it ( "does not include search params when action=''" , async ( ) => {
2635
2635
let router = createTestRouter (
2636
2636
createRoutesFromElements (
2637
2637
< Route path = "/" >
@@ -2655,7 +2655,7 @@ function testDomRouter(
2655
2655
} ) ;
2656
2656
2657
2657
describe ( "index routes" , ( ) => {
2658
- it ( "includes search params + hash when no action is specified" , async ( ) => {
2658
+ it ( "includes search params when no action is specified" , async ( ) => {
2659
2659
let router = createTestRouter (
2660
2660
createRoutesFromElements (
2661
2661
< Route path = "/" >
@@ -2673,11 +2673,11 @@ function testDomRouter(
2673
2673
let { container } = render ( < RouterProvider router = { router } /> ) ;
2674
2674
2675
2675
expect ( container . querySelector ( "form" ) ?. getAttribute ( "action" ) ) . toBe (
2676
- "/foo/bar?index&a=1#hash "
2676
+ "/foo/bar?index&a=1"
2677
2677
) ;
2678
2678
} ) ;
2679
2679
2680
- it ( "does not include search params + hash action='.'" , async ( ) => {
2680
+ it ( "does not include search params action='.'" , async ( ) => {
2681
2681
let router = createTestRouter (
2682
2682
createRoutesFromElements (
2683
2683
< Route path = "/" >
@@ -2699,7 +2699,7 @@ function testDomRouter(
2699
2699
) ;
2700
2700
} ) ;
2701
2701
2702
- it ( "does not include search params + hash action=''" , async ( ) => {
2702
+ it ( "does not include search params action=''" , async ( ) => {
2703
2703
let router = createTestRouter (
2704
2704
createRoutesFromElements (
2705
2705
< Route path = "/" >
@@ -2777,7 +2777,7 @@ function testDomRouter(
2777
2777
let { container } = render ( < RouterProvider router = { router } /> ) ;
2778
2778
2779
2779
expect ( container . querySelector ( "form" ) ?. getAttribute ( "action" ) ) . toBe (
2780
- "/foo/bar?index&a=1#hash "
2780
+ "/foo/bar?index&a=1"
2781
2781
) ;
2782
2782
} ) ;
2783
2783
@@ -2816,7 +2816,7 @@ function testDomRouter(
2816
2816
} ) ;
2817
2817
2818
2818
describe ( "dynamic routes" , ( ) => {
2819
- it ( "includes search params + hash when no action is specified" , async ( ) => {
2819
+ it ( "includes search params when no action is specified" , async ( ) => {
2820
2820
let router = createTestRouter (
2821
2821
createRoutesFromElements (
2822
2822
< Route path = "/" >
@@ -2832,11 +2832,11 @@ function testDomRouter(
2832
2832
let { container } = render ( < RouterProvider router = { router } /> ) ;
2833
2833
2834
2834
expect ( container . querySelector ( "form" ) ?. getAttribute ( "action" ) ) . toBe (
2835
- "/foo/bar?a=1#hash "
2835
+ "/foo/bar?a=1"
2836
2836
) ;
2837
2837
} ) ;
2838
2838
2839
- it ( "does not include search params + hash action='.'" , async ( ) => {
2839
+ it ( "does not include search params action='.'" , async ( ) => {
2840
2840
let router = createTestRouter (
2841
2841
createRoutesFromElements (
2842
2842
< Route path = "/" >
@@ -2856,7 +2856,7 @@ function testDomRouter(
2856
2856
) ;
2857
2857
} ) ;
2858
2858
2859
- it ( "does not include search params + hash when action=''" , async ( ) => {
2859
+ it ( "does not include search params when action=''" , async ( ) => {
2860
2860
let router = createTestRouter (
2861
2861
createRoutesFromElements (
2862
2862
< Route path = "/" >
@@ -2878,7 +2878,7 @@ function testDomRouter(
2878
2878
} ) ;
2879
2879
2880
2880
describe ( "splat routes" , ( ) => {
2881
- it ( "includes search params + hash when no action is specified" , async ( ) => {
2881
+ it ( "includes search params when no action is specified" , async ( ) => {
2882
2882
let router = createTestRouter (
2883
2883
createRoutesFromElements (
2884
2884
< Route path = "/" >
@@ -2894,11 +2894,11 @@ function testDomRouter(
2894
2894
let { container } = render ( < RouterProvider router = { router } /> ) ;
2895
2895
2896
2896
expect ( container . querySelector ( "form" ) ?. getAttribute ( "action" ) ) . toBe (
2897
- "/foo?a=1#hash "
2897
+ "/foo?a=1"
2898
2898
) ;
2899
2899
} ) ;
2900
2900
2901
- it ( "does not include search params + hash when action='.'" , async ( ) => {
2901
+ it ( "does not include search params when action='.'" , async ( ) => {
2902
2902
let router = createTestRouter (
2903
2903
createRoutesFromElements (
2904
2904
< Route path = "/" >
@@ -2918,7 +2918,7 @@ function testDomRouter(
2918
2918
) ;
2919
2919
} ) ;
2920
2920
2921
- it ( "does not include search params + hash when action=''" , async ( ) => {
2921
+ it ( "does not include search params when action=''" , async ( ) => {
2922
2922
let router = createTestRouter (
2923
2923
createRoutesFromElements (
2924
2924
< Route path = "/" >
@@ -2938,6 +2938,24 @@ function testDomRouter(
2938
2938
) ;
2939
2939
} ) ;
2940
2940
} ) ;
2941
+
2942
+ it ( "allows user to specify search params and hash" , async ( ) => {
2943
+ let router = createTestRouter (
2944
+ createRoutesFromElements (
2945
+ < Route path = "/" >
2946
+ < Route path = "foo" >
2947
+ < Route path = "bar" element = { < Form action = ".?a=1#newhash" /> } />
2948
+ </ Route >
2949
+ </ Route >
2950
+ ) ,
2951
+ { window : getWindow ( "/foo/bar?a=1#hash" ) }
2952
+ ) ;
2953
+ let { container } = render ( < RouterProvider router = { router } /> ) ;
2954
+
2955
+ expect ( container . querySelector ( "form" ) ?. getAttribute ( "action" ) ) . toBe (
2956
+ "/foo/bar?a=1#newhash"
2957
+ ) ;
2958
+ } ) ;
2941
2959
} ) ;
2942
2960
2943
2961
describe ( '<Form action relative="path">' , ( ) => {
0 commit comments