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
@@ -736,6 +737,7 @@ where
736737 name : subject,
737738 self_closing : false ,
738739 attrs : vec ! [ ] ,
740+ had_duplicate_attrs : false ,
739741 } ) ;
740742 } ;
741743
@@ -831,10 +833,11 @@ where
831833 } ;
832834 // FIXME: Is there a way to avoid cloning the attributes twice here (once on their
833835 // own, once as part of t.clone() above)?
834- let new_element = create_element (
836+ let new_element = create_element_with_flags (
835837 & self . sink ,
836838 QualName :: new ( None , ns ! ( html) , tag. name . clone ( ) ) ,
837839 tag. attrs . clone ( ) ,
840+ tag. had_duplicate_attrs ,
838841 ) ;
839842 self . open_elems . borrow_mut ( ) [ node_index] = new_element. clone ( ) ;
840843 self . active_formatting . borrow_mut ( ) [ node_formatting_index] =
@@ -863,10 +866,11 @@ where
863866 // 15.
864867 // FIXME: Is there a way to avoid cloning the attributes twice here (once on their own,
865868 // once as part of t.clone() above)?
866- let new_element = create_element (
869+ let new_element = create_element_with_flags (
867870 & self . sink ,
868871 QualName :: new ( None , ns ! ( html) , fmt_elem_tag. name . clone ( ) ) ,
869872 fmt_elem_tag. attrs . clone ( ) ,
873+ fmt_elem_tag. had_duplicate_attrs ,
870874 ) ;
871875 let new_entry = FormatEntry :: Element ( new_element. clone ( ) , fmt_elem_tag) ;
872876
@@ -1014,6 +1018,7 @@ where
10141018 ns ! ( html) ,
10151019 tag. name . clone ( ) ,
10161020 tag. attrs . clone ( ) ,
1021+ tag. had_duplicate_attrs ,
10171022 ) ;
10181023
10191024 // Step 9. Replace the entry for entry in the list with an entry for new element.
@@ -1358,6 +1363,7 @@ where
13581363 ns : Namespace ,
13591364 name : LocalName ,
13601365 attrs : Vec < Attribute > ,
1366+ had_duplicate_attrs : bool ,
13611367 ) -> Handle {
13621368 declare_tag_set ! ( form_associatable =
13631369 "button" "fieldset" "input" "object"
@@ -1367,7 +1373,12 @@ where
13671373
13681374 // Step 7.
13691375 let qname = QualName :: new ( None , ns, name) ;
1370- let elem = create_element ( & self . sink , qname. clone ( ) , attrs. clone ( ) ) ;
1376+ let elem = create_element_with_flags (
1377+ & self . sink ,
1378+ qname. clone ( ) ,
1379+ attrs. clone ( ) ,
1380+ had_duplicate_attrs,
1381+ ) ;
13711382
13721383 let insertion_point = self . appropriate_place_for_insertion ( None ) ;
13731384 let ( node1, node2) = match insertion_point {
@@ -1405,15 +1416,27 @@ where
14051416 }
14061417
14071418 fn insert_element_for ( & self , tag : Tag ) -> Handle {
1408- self . insert_element ( PushFlag :: Push , ns ! ( html) , tag. name , tag. attrs )
1419+ self . insert_element (
1420+ PushFlag :: Push ,
1421+ ns ! ( html) ,
1422+ tag. name ,
1423+ tag. attrs ,
1424+ tag. had_duplicate_attrs ,
1425+ )
14091426 }
14101427
14111428 fn insert_and_pop_element_for ( & self , tag : Tag ) -> Handle {
1412- self . insert_element ( PushFlag :: NoPush , ns ! ( html) , tag. name , tag. attrs )
1429+ self . insert_element (
1430+ PushFlag :: NoPush ,
1431+ ns ! ( html) ,
1432+ tag. name ,
1433+ tag. attrs ,
1434+ tag. had_duplicate_attrs ,
1435+ )
14131436 }
14141437
14151438 fn insert_phantom ( & self , name : LocalName ) -> Handle {
1416- self . insert_element ( PushFlag :: Push , ns ! ( html) , name, vec ! [ ] )
1439+ self . insert_element ( PushFlag :: Push , ns ! ( html) , name, vec ! [ ] , false )
14171440 }
14181441
14191442 /// <https://html.spec.whatwg.org/multipage/parsing.html#insert-an-element-at-the-adjusted-insertion-location>
@@ -1424,8 +1447,13 @@ where
14241447 only_add_to_element_stack : bool ,
14251448 ) -> Handle {
14261449 let adjusted_insertion_location = self . appropriate_place_for_insertion ( None ) ;
1427- let qname = QualName :: new ( None , ns, tag. name ) ;
1428- let elem = create_element ( & self . sink , qname. clone ( ) , tag. attrs . clone ( ) ) ;
1450+ let qname = QualName :: new ( None , ns, tag. name . clone ( ) ) ;
1451+ let elem = create_element_with_flags (
1452+ & self . sink ,
1453+ qname. clone ( ) ,
1454+ tag. attrs . clone ( ) ,
1455+ tag. had_duplicate_attrs ,
1456+ ) ;
14291457
14301458 if !only_add_to_element_stack {
14311459 self . insert_at ( adjusted_insertion_location, AppendNode ( elem. clone ( ) ) ) ;
@@ -1515,6 +1543,7 @@ where
15151543 ns ! ( html) ,
15161544 tag. name . clone ( ) ,
15171545 tag. attrs . clone ( ) ,
1546+ tag. had_duplicate_attrs ,
15181547 ) ;
15191548 self . active_formatting
15201549 . borrow_mut ( )
@@ -1650,10 +1679,22 @@ where
16501679 self . adjust_foreign_attributes ( & mut tag) ;
16511680
16521681 if tag. self_closing {
1653- self . insert_element ( PushFlag :: NoPush , ns, tag. name , tag. attrs ) ;
1682+ self . insert_element (
1683+ PushFlag :: NoPush ,
1684+ ns,
1685+ tag. name ,
1686+ tag. attrs ,
1687+ tag. had_duplicate_attrs ,
1688+ ) ;
16541689 ProcessResult :: DoneAckSelfClosing
16551690 } else {
1656- self . insert_element ( PushFlag :: Push , ns, tag. name , tag. attrs ) ;
1691+ self . insert_element (
1692+ PushFlag :: Push ,
1693+ ns,
1694+ tag. name ,
1695+ tag. attrs ,
1696+ tag. had_duplicate_attrs ,
1697+ ) ;
16571698 ProcessResult :: Done
16581699 }
16591700 }
@@ -1818,10 +1859,22 @@ where
18181859 self . adjust_foreign_attributes ( & mut tag) ;
18191860 if tag. self_closing {
18201861 // FIXME(#118): <script /> in SVG
1821- self . insert_element ( PushFlag :: NoPush , current_ns, tag. name , tag. attrs ) ;
1862+ self . insert_element (
1863+ PushFlag :: NoPush ,
1864+ current_ns,
1865+ tag. name ,
1866+ tag. attrs ,
1867+ tag. had_duplicate_attrs ,
1868+ ) ;
18221869 ProcessResult :: DoneAckSelfClosing
18231870 } else {
1824- self . insert_element ( PushFlag :: Push , current_ns, tag. name , tag. attrs ) ;
1871+ self . insert_element (
1872+ PushFlag :: Push ,
1873+ current_ns,
1874+ tag. name ,
1875+ tag. attrs ,
1876+ tag. had_duplicate_attrs ,
1877+ ) ;
18251878 ProcessResult :: Done
18261879 }
18271880 }
0 commit comments