File tree 1 file changed +84
-0
lines changed
packages/react-dom/src/__tests__
1 file changed +84
-0
lines changed Original file line number Diff line number Diff line change @@ -5386,6 +5386,90 @@ describe('ReactDOMFloat', () => {
5386
5386
} ) ;
5387
5387
5388
5388
describe ( 'resource free contexts' , ( ) => {
5389
+ // @gate enableFloat
5390
+ it ( 'allows resources inside foreignobject within an svg context' , async ( ) => {
5391
+ await actIntoEmptyDocument ( ( ) => {
5392
+ const { pipe} = ReactDOMFizzServer . renderToPipeableStream (
5393
+ < html >
5394
+ < body >
5395
+ < svg >
5396
+ < foreignObject >
5397
+ < title > foo</ title >
5398
+ </ foreignObject >
5399
+ </ svg >
5400
+ </ body >
5401
+ </ html > ,
5402
+ ) ;
5403
+ pipe ( writable ) ;
5404
+ } ) ;
5405
+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
5406
+ < html >
5407
+ < head >
5408
+ < title > foo</ title >
5409
+ </ head >
5410
+ < body >
5411
+ < svg >
5412
+ < foreignobject />
5413
+ </ svg >
5414
+ </ body >
5415
+ </ html > ,
5416
+ ) ;
5417
+
5418
+ let root = ReactDOMClient . hydrateRoot (
5419
+ document ,
5420
+ < html >
5421
+ < body >
5422
+ < svg >
5423
+ < foreignObject >
5424
+ < title > foo</ title >
5425
+ </ foreignObject >
5426
+ </ svg >
5427
+ </ body >
5428
+ </ html > ,
5429
+ ) ;
5430
+ expect ( Scheduler ) . toFlushWithoutYielding ( ) ;
5431
+ // @TODO the preload should not get inserted on hydration
5432
+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
5433
+ < html >
5434
+ < head >
5435
+ < title > foo</ title >
5436
+ </ head >
5437
+ < body >
5438
+ < svg >
5439
+ < foreignobject />
5440
+ </ svg >
5441
+ </ body >
5442
+ </ html > ,
5443
+ ) ;
5444
+
5445
+ root . unmount ( ) ;
5446
+ root = ReactDOMClient . createRoot ( document ) ;
5447
+ root . render (
5448
+ < html >
5449
+ < body >
5450
+ < svg >
5451
+ < foreignObject >
5452
+ < title > foo</ title >
5453
+ </ foreignObject >
5454
+ </ svg >
5455
+ </ body >
5456
+ </ html > ,
5457
+ ) ;
5458
+ expect ( Scheduler ) . toFlushWithoutYielding ( ) ;
5459
+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
5460
+ < html >
5461
+ < head >
5462
+ < title > foo</ title >
5463
+ </ head >
5464
+ < body >
5465
+ < svg >
5466
+ < foreignobject />
5467
+ </ svg >
5468
+ </ body >
5469
+ </ html > ,
5470
+ ) ;
5471
+ } ) ;
5472
+
5389
5473
// @gate enableFloat
5390
5474
it ( 'warns if you render something that is almost a resource inside an svg tree' , async ( ) => {
5391
5475
const root = ReactDOMClient . createRoot ( container ) ;
You can’t perform that action at this time.
0 commit comments