@@ -274,15 +274,18 @@ type InsertionMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
274
274
export type FormatContext = {
275
275
insertionMode : InsertionMode , // root/svg/html/mathml/table
276
276
selectedValue : null | string | Array < string > , // the selected value(s) inside a <select>, or null outside <select>
277
+ noscriptTagInScope : boolean ,
277
278
} ;
278
279
279
280
function createFormatContext (
280
281
insertionMode : InsertionMode ,
281
282
selectedValue : null | string ,
283
+ noscriptTagInScope : boolean ,
282
284
) : FormatContext {
283
285
return {
284
286
insertionMode ,
285
287
selectedValue ,
288
+ noscriptTagInScope ,
286
289
} ;
287
290
}
288
291
@@ -293,7 +296,7 @@ export function createRootFormatContext(namespaceURI?: string): FormatContext {
293
296
: namespaceURI === 'http://www.w3.org/1998/Math/MathML'
294
297
? MATHML_MODE
295
298
: ROOT_HTML_MODE ;
296
- return createFormatContext ( insertionMode , null ) ;
299
+ return createFormatContext ( insertionMode , null , false ) ;
297
300
}
298
301
299
302
export function getChildFormatContext (
@@ -302,38 +305,77 @@ export function getChildFormatContext(
302
305
props : Object ,
303
306
) : FormatContext {
304
307
switch ( type ) {
308
+ case 'noscript' :
309
+ return createFormatContext ( HTML_MODE , null , true ) ;
305
310
case 'select' :
306
311
return createFormatContext (
307
312
HTML_MODE ,
308
313
props . value != null ? props . value : props . defaultValue ,
314
+ parentContext . noscriptTagInScope ,
309
315
) ;
310
316
case 'svg' :
311
- return createFormatContext ( SVG_MODE , null ) ;
317
+ return createFormatContext (
318
+ SVG_MODE ,
319
+ null ,
320
+ parentContext . noscriptTagInScope ,
321
+ ) ;
312
322
case 'math' :
313
- return createFormatContext ( MATHML_MODE , null ) ;
323
+ return createFormatContext (
324
+ MATHML_MODE ,
325
+ null ,
326
+ parentContext . noscriptTagInScope ,
327
+ ) ;
314
328
case 'foreignObject' :
315
- return createFormatContext ( HTML_MODE , null ) ;
329
+ return createFormatContext (
330
+ HTML_MODE ,
331
+ null ,
332
+ parentContext . noscriptTagInScope ,
333
+ ) ;
316
334
// Table parents are special in that their children can only be created at all if they're
317
335
// wrapped in a table parent. So we need to encode that we're entering this mode.
318
336
case 'table' :
319
- return createFormatContext ( HTML_TABLE_MODE , null ) ;
337
+ return createFormatContext (
338
+ HTML_TABLE_MODE ,
339
+ null ,
340
+ parentContext . noscriptTagInScope ,
341
+ ) ;
320
342
case 'thead' :
321
343
case 'tbody' :
322
344
case 'tfoot' :
323
- return createFormatContext ( HTML_TABLE_BODY_MODE , null ) ;
345
+ return createFormatContext (
346
+ HTML_TABLE_BODY_MODE ,
347
+ null ,
348
+ parentContext . noscriptTagInScope ,
349
+ ) ;
324
350
case 'colgroup' :
325
- return createFormatContext ( HTML_COLGROUP_MODE , null ) ;
351
+ return createFormatContext (
352
+ HTML_COLGROUP_MODE ,
353
+ null ,
354
+ parentContext . noscriptTagInScope ,
355
+ ) ;
326
356
case 'tr' :
327
- return createFormatContext ( HTML_TABLE_ROW_MODE , null ) ;
357
+ return createFormatContext (
358
+ HTML_TABLE_ROW_MODE ,
359
+ null ,
360
+ parentContext . noscriptTagInScope ,
361
+ ) ;
328
362
}
329
363
if ( parentContext . insertionMode >= HTML_TABLE_MODE ) {
330
364
// Whatever tag this was, it wasn't a table parent or other special parent, so we must have
331
365
// entered plain HTML again.
332
- return createFormatContext ( HTML_MODE , null ) ;
366
+ return createFormatContext (
367
+ HTML_MODE ,
368
+ null ,
369
+ parentContext . noscriptTagInScope ,
370
+ ) ;
333
371
}
334
372
if ( parentContext . insertionMode === ROOT_HTML_MODE ) {
335
373
// We've emitted the root and is now in plain HTML mode.
336
- return createFormatContext ( HTML_MODE , null ) ;
374
+ return createFormatContext (
375
+ HTML_MODE ,
376
+ null ,
377
+ parentContext . noscriptTagInScope ,
378
+ ) ;
337
379
}
338
380
return parentContext ;
339
381
}
@@ -1155,8 +1197,13 @@ function pushBase(
1155
1197
props : Object ,
1156
1198
responseState : ResponseState ,
1157
1199
textEmbedded : boolean ,
1200
+ noscriptTagInScope : boolean ,
1158
1201
) : ReactNodeList {
1159
- if ( enableFloat && resourcesFromElement ( 'base' , props ) ) {
1202
+ if (
1203
+ enableFloat &&
1204
+ ! noscriptTagInScope &&
1205
+ resourcesFromElement ( 'base' , props )
1206
+ ) {
1160
1207
if ( textEmbedded ) {
1161
1208
// This link follows text but we aren't writing a tag. while not as efficient as possible we need
1162
1209
// to be safe and assume text will follow by inserting a textSeparator
@@ -1175,8 +1222,13 @@ function pushMeta(
1175
1222
props : Object ,
1176
1223
responseState : ResponseState ,
1177
1224
textEmbedded : boolean ,
1225
+ noscriptTagInScope : boolean ,
1178
1226
) : ReactNodeList {
1179
- if ( enableFloat && resourcesFromElement ( 'meta' , props ) ) {
1227
+ if (
1228
+ enableFloat &&
1229
+ ! noscriptTagInScope &&
1230
+ resourcesFromElement ( 'meta' , props )
1231
+ ) {
1180
1232
if ( textEmbedded ) {
1181
1233
// This link follows text but we aren't writing a tag. while not as efficient as possible we need
1182
1234
// to be safe and assume text will follow by inserting a textSeparator
@@ -1195,8 +1247,9 @@ function pushLink(
1195
1247
props : Object ,
1196
1248
responseState : ResponseState ,
1197
1249
textEmbedded : boolean ,
1250
+ noscriptTagInScope : boolean ,
1198
1251
) : ReactNodeList {
1199
- if ( enableFloat && resourcesFromLink ( props ) ) {
1252
+ if ( enableFloat && ! noscriptTagInScope && resourcesFromLink ( props ) ) {
1200
1253
if ( textEmbedded ) {
1201
1254
// This link follows text but we aren't writing a tag. while not as efficient as possible we need
1202
1255
// to be safe and assume text will follow by inserting a textSeparator
@@ -1318,6 +1371,7 @@ function pushTitle(
1318
1371
target : Array < Chunk | PrecomputedChunk > ,
1319
1372
props : Object ,
1320
1373
responseState : ResponseState ,
1374
+ noscriptTagInScope : boolean ,
1321
1375
) : ReactNodeList {
1322
1376
if ( __DEV__ ) {
1323
1377
const children = props . children ;
@@ -1359,7 +1413,11 @@ function pushTitle(
1359
1413
}
1360
1414
}
1361
1415
1362
- if ( enableFloat && resourcesFromElement ( 'title' , props ) ) {
1416
+ if (
1417
+ enableFloat &&
1418
+ ! noscriptTagInScope &&
1419
+ resourcesFromElement ( 'title' , props )
1420
+ ) {
1363
1421
// We have converted this link exclusively to a resource and no longer
1364
1422
// need to emit it
1365
1423
return null ;
@@ -1520,8 +1578,9 @@ function pushScript(
1520
1578
props : Object ,
1521
1579
responseState : ResponseState ,
1522
1580
textEmbedded : boolean ,
1581
+ noscriptTagInScope : boolean ,
1523
1582
) : null {
1524
- if ( enableFloat && resourcesFromScript ( props ) ) {
1583
+ if ( enableFloat && ! noscriptTagInScope && resourcesFromScript ( props ) ) {
1525
1584
if ( textEmbedded ) {
1526
1585
// This link follows text but we aren't writing a tag. while not as efficient as possible we need
1527
1586
// to be safe and assume text will follow by inserting a textSeparator
@@ -1863,18 +1922,47 @@ export function pushStartInstance(
1863
1922
return pushStartMenuItem ( target , props , responseState ) ;
1864
1923
case 'title ':
1865
1924
return enableFloat
1866
- ? pushTitle ( target , props , responseState )
1925
+ ? pushTitle (
1926
+ target ,
1927
+ props ,
1928
+ responseState ,
1929
+ formatContext . noscriptTagInScope ,
1930
+ )
1867
1931
: pushStartTitle ( target , props , responseState ) ;
1868
1932
case 'link ':
1869
- return pushLink ( target , props , responseState , textEmbedded ) ;
1933
+ return pushLink (
1934
+ target ,
1935
+ props ,
1936
+ responseState ,
1937
+ textEmbedded ,
1938
+ formatContext . noscriptTagInScope ,
1939
+ ) ;
1870
1940
case 'script ':
1871
1941
return enableFloat
1872
- ? pushScript ( target , props , responseState , textEmbedded )
1942
+ ? pushScript (
1943
+ target ,
1944
+ props ,
1945
+ responseState ,
1946
+ textEmbedded ,
1947
+ formatContext . noscriptTagInScope ,
1948
+ )
1873
1949
: pushStartGenericElement ( target , props , type , responseState ) ;
1874
1950
case 'meta':
1875
- return pushMeta ( target , props , responseState , textEmbedded ) ;
1951
+ return pushMeta (
1952
+ target ,
1953
+ props ,
1954
+ responseState ,
1955
+ textEmbedded ,
1956
+ formatContext . noscriptTagInScope ,
1957
+ ) ;
1876
1958
case 'base ':
1877
- return pushBase ( target , props , responseState , textEmbedded ) ;
1959
+ return pushBase (
1960
+ target ,
1961
+ props ,
1962
+ responseState ,
1963
+ textEmbedded ,
1964
+ formatContext . noscriptTagInScope ,
1965
+ ) ;
1878
1966
// Newline eating tags
1879
1967
case 'listing ':
1880
1968
case 'pre ': {
0 commit comments