@@ -1376,8 +1376,31 @@ where
1376
1376
fn insert_phantom ( & self , name : LocalName ) -> Handle {
1377
1377
self . insert_element ( Push , ns ! ( html) , name, vec ! [ ] )
1378
1378
}
1379
+
1380
+ /// <https://html.spec.whatwg.org/multipage/parsing.html#insert-an-element-at-the-adjusted-insertion-location>
1381
+ fn insert_foreign_element (
1382
+ & self ,
1383
+ tag : Tag ,
1384
+ ns : Namespace ,
1385
+ only_add_to_element_stack : bool ,
1386
+ ) -> Handle {
1387
+ let adjusted_insertion_location = self . appropriate_place_for_insertion ( None ) ;
1388
+ let qname = QualName :: new ( None , ns, tag. name ) ;
1389
+ let elem = create_element ( & self . sink , qname. clone ( ) , tag. attrs . clone ( ) ) ;
1390
+
1391
+ if !only_add_to_element_stack {
1392
+ self . insert_at ( adjusted_insertion_location, AppendNode ( elem. clone ( ) ) ) ;
1393
+ }
1394
+
1395
+ self . push ( & elem) ;
1396
+
1397
+ elem
1398
+ }
1379
1399
//§ END
1380
1400
1401
+ /// <https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead>
1402
+ ///
1403
+ /// A start tag whose tag name is "template"
1381
1404
fn should_attach_declarative_shadow ( & self , tag : & Tag ) -> bool {
1382
1405
let adjusted_insertion_location = self . appropriate_place_for_insertion ( None ) ;
1383
1406
@@ -1392,7 +1415,7 @@ where
1392
1415
// template start tag's shadowrootmode is not in the none state
1393
1416
let is_shadow_root_mode = tag. attrs . iter ( ) . any ( |attr| {
1394
1417
attr. name . local == local_name ! ( "shadowrootmode" )
1395
- && ( attr. value . to_string ( ) == * "open" || attr. value . to_string ( ) == * "close ")
1418
+ && ( attr. value . as_ref ( ) == "open" || attr. value . as_ref ( ) == "closed ")
1396
1419
} ) ;
1397
1420
1398
1421
// Check if intended_parent's document allows declarative shadow roots
@@ -1416,9 +1439,17 @@ where
1416
1439
is_shadow_root_mode && allow_declarative_shadow_roots && adjusted_current_node_not_topmost
1417
1440
}
1418
1441
1419
- fn attach_declarative_shadow ( & self , tag : & Tag ) -> Result < ( ) , String > {
1442
+ /// <https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead>
1443
+ ///
1444
+ /// A start tag whose tag name is "template"
1445
+ fn attach_declarative_shadow (
1446
+ & self ,
1447
+ tag : & Tag ,
1448
+ shadow_host : & Handle ,
1449
+ template : & Handle ,
1450
+ ) -> Result < ( ) , String > {
1420
1451
self . sink
1421
- . attach_declarative_shadow ( self . open_elems . borrow ( ) . last ( ) . unwrap ( ) , tag. attrs . clone ( ) )
1452
+ . attach_declarative_shadow ( shadow_host , template , tag. attrs . clone ( ) )
1422
1453
}
1423
1454
1424
1455
fn create_formatting_element_for ( & self , tag : Tag ) -> Handle {
0 commit comments