1212pub use crate :: interface:: { create_element, ElemName , ElementFlags , Tracer , TreeSink } ;
1313pub use crate :: interface:: { AppendNode , AppendText , Attribute , NodeOrText } ;
1414pub use crate :: interface:: { LimitedQuirks , NoQuirks , Quirks , QuirksMode } ;
15+ pub use markup5ever:: interface:: tree_builder:: create_element_with_flags;
1516
1617use self :: types:: * ;
1718
@@ -733,6 +734,7 @@ where
733734 name : subject,
734735 self_closing : false ,
735736 attrs : vec ! [ ] ,
737+ had_duplicate_attrs : false ,
736738 } ) ;
737739 } ;
738740
@@ -828,10 +830,11 @@ where
828830 } ;
829831 // FIXME: Is there a way to avoid cloning the attributes twice here (once on their
830832 // own, once as part of t.clone() above)?
831- let new_element = create_element (
833+ let new_element = create_element_with_flags (
832834 & self . sink ,
833835 QualName :: new ( None , ns ! ( html) , tag. name . clone ( ) ) ,
834836 tag. attrs . clone ( ) ,
837+ tag. had_duplicate_attrs ,
835838 ) ;
836839 self . open_elems . borrow_mut ( ) [ node_index] = new_element. clone ( ) ;
837840 self . active_formatting . borrow_mut ( ) [ node_formatting_index] =
@@ -860,10 +863,11 @@ where
860863 // 15.
861864 // FIXME: Is there a way to avoid cloning the attributes twice here (once on their own,
862865 // once as part of t.clone() above)?
863- let new_element = create_element (
866+ let new_element = create_element_with_flags (
864867 & self . sink ,
865868 QualName :: new ( None , ns ! ( html) , fmt_elem_tag. name . clone ( ) ) ,
866869 fmt_elem_tag. attrs . clone ( ) ,
870+ fmt_elem_tag. had_duplicate_attrs ,
867871 ) ;
868872 let new_entry = FormatEntry :: Element ( new_element. clone ( ) , fmt_elem_tag) ;
869873
@@ -1010,6 +1014,7 @@ where
10101014 ns ! ( html) ,
10111015 tag. name . clone ( ) ,
10121016 tag. attrs . clone ( ) ,
1017+ tag. had_duplicate_attrs ,
10131018 ) ;
10141019
10151020 // Step 9. Replace the entry for entry in the list with an entry for new element.
@@ -1363,6 +1368,7 @@ where
13631368 ns : Namespace ,
13641369 name : LocalName ,
13651370 attrs : Vec < Attribute > ,
1371+ had_duplicate_attrs : bool ,
13661372 ) -> Handle {
13671373 declare_tag_set ! ( form_associatable =
13681374 "button" "fieldset" "input" "object"
@@ -1372,7 +1378,12 @@ where
13721378
13731379 // Step 7.
13741380 let qname = QualName :: new ( None , ns, name) ;
1375- let elem = create_element ( & self . sink , qname. clone ( ) , attrs. clone ( ) ) ;
1381+ let elem = create_element_with_flags (
1382+ & self . sink ,
1383+ qname. clone ( ) ,
1384+ attrs. clone ( ) ,
1385+ had_duplicate_attrs,
1386+ ) ;
13761387
13771388 let insertion_point = self . appropriate_place_for_insertion ( None ) ;
13781389 let ( node1, node2) = match insertion_point {
@@ -1410,15 +1421,27 @@ where
14101421 }
14111422
14121423 fn insert_element_for ( & self , tag : Tag ) -> Handle {
1413- self . insert_element ( PushFlag :: Push , ns ! ( html) , tag. name , tag. attrs )
1424+ self . insert_element (
1425+ PushFlag :: Push ,
1426+ ns ! ( html) ,
1427+ tag. name ,
1428+ tag. attrs ,
1429+ tag. had_duplicate_attrs ,
1430+ )
14141431 }
14151432
14161433 fn insert_and_pop_element_for ( & self , tag : Tag ) -> Handle {
1417- self . insert_element ( PushFlag :: NoPush , ns ! ( html) , tag. name , tag. attrs )
1434+ self . insert_element (
1435+ PushFlag :: NoPush ,
1436+ ns ! ( html) ,
1437+ tag. name ,
1438+ tag. attrs ,
1439+ tag. had_duplicate_attrs ,
1440+ )
14181441 }
14191442
14201443 fn insert_phantom ( & self , name : LocalName ) -> Handle {
1421- self . insert_element ( PushFlag :: Push , ns ! ( html) , name, vec ! [ ] )
1444+ self . insert_element ( PushFlag :: Push , ns ! ( html) , name, vec ! [ ] , false )
14221445 }
14231446
14241447 /// <https://html.spec.whatwg.org/multipage/parsing.html#insert-an-element-at-the-adjusted-insertion-location>
@@ -1429,8 +1452,13 @@ where
14291452 only_add_to_element_stack : bool ,
14301453 ) -> Handle {
14311454 let adjusted_insertion_location = self . appropriate_place_for_insertion ( None ) ;
1432- let qname = QualName :: new ( None , ns, tag. name ) ;
1433- let elem = create_element ( & self . sink , qname. clone ( ) , tag. attrs . clone ( ) ) ;
1455+ let qname = QualName :: new ( None , ns, tag. name . clone ( ) ) ;
1456+ let elem = create_element_with_flags (
1457+ & self . sink ,
1458+ qname. clone ( ) ,
1459+ tag. attrs . clone ( ) ,
1460+ tag. had_duplicate_attrs ,
1461+ ) ;
14341462
14351463 if !only_add_to_element_stack {
14361464 self . insert_at ( adjusted_insertion_location, AppendNode ( elem. clone ( ) ) ) ;
@@ -1520,6 +1548,7 @@ where
15201548 ns ! ( html) ,
15211549 tag. name . clone ( ) ,
15221550 tag. attrs . clone ( ) ,
1551+ tag. had_duplicate_attrs ,
15231552 ) ;
15241553 self . active_formatting
15251554 . borrow_mut ( )
@@ -1655,10 +1684,22 @@ where
16551684 self . adjust_foreign_attributes ( & mut tag) ;
16561685
16571686 if tag. self_closing {
1658- self . insert_element ( PushFlag :: NoPush , ns, tag. name , tag. attrs ) ;
1687+ self . insert_element (
1688+ PushFlag :: NoPush ,
1689+ ns,
1690+ tag. name ,
1691+ tag. attrs ,
1692+ tag. had_duplicate_attrs ,
1693+ ) ;
16591694 ProcessResult :: DoneAckSelfClosing
16601695 } else {
1661- self . insert_element ( PushFlag :: Push , ns, tag. name , tag. attrs ) ;
1696+ self . insert_element (
1697+ PushFlag :: Push ,
1698+ ns,
1699+ tag. name ,
1700+ tag. attrs ,
1701+ tag. had_duplicate_attrs ,
1702+ ) ;
16621703 ProcessResult :: Done
16631704 }
16641705 }
@@ -1823,10 +1864,22 @@ where
18231864 self . adjust_foreign_attributes ( & mut tag) ;
18241865 if tag. self_closing {
18251866 // FIXME(#118): <script /> in SVG
1826- self . insert_element ( PushFlag :: NoPush , current_ns, tag. name , tag. attrs ) ;
1867+ self . insert_element (
1868+ PushFlag :: NoPush ,
1869+ current_ns,
1870+ tag. name ,
1871+ tag. attrs ,
1872+ tag. had_duplicate_attrs ,
1873+ ) ;
18271874 ProcessResult :: DoneAckSelfClosing
18281875 } else {
1829- self . insert_element ( PushFlag :: Push , current_ns, tag. name , tag. attrs ) ;
1876+ self . insert_element (
1877+ PushFlag :: Push ,
1878+ current_ns,
1879+ tag. name ,
1880+ tag. attrs ,
1881+ tag. had_duplicate_attrs ,
1882+ ) ;
18301883 ProcessResult :: Done
18311884 }
18321885 }
0 commit comments