@@ -337,13 +337,19 @@ function TestElement.test_append_element()
337337 })
338338end
339339
340+ local function normalize_attributes_order (text )
341+ local normalized_text , n_substitutions =
342+ text :gsub ([[ class="A" id="1"]] , [[ id="1" class="A"]] )
343+ return normalized_text
344+ end
345+
340346function TestElement .test_append_element_with_attribute ()
341347 local document = xmlua .XML .parse (" <root/>" )
342348 local root = document :root ()
343349 local child = root :append_element (" child" , {id = " 1" , class = " A" })
344350 luaunit .assertEquals ({
345- child :to_xml (),
346- document :to_xml (),
351+ normalize_attributes_order ( child :to_xml () ),
352+ normalize_attributes_order ( document :to_xml () ),
347353 },
348354 {
349355 [[ <child id="1" class="A"/>]] ,
@@ -365,9 +371,9 @@ function TestElement.test_append_element_with_namespace()
365371 local root = document :root ()
366372 local child = root :append_element (" xhtml:child" , {id = " 1" , class = " A" })
367373 luaunit .assertEquals ({
368- child :to_xml (),
374+ normalize_attributes_order ( child :to_xml () ),
369375 ffi .string (child .node .ns .href ),
370- document :to_xml (),
376+ normalize_attributes_order ( document :to_xml () ),
371377 },
372378 {
373379 [[ <xhtml:child id="1" class="A"/>]] ,
@@ -567,8 +573,8 @@ function TestElement.test_insert_element_with_attributes()
567573 local root = document :root ()
568574 local child = root :insert_element (2 , " new-child" , {id = " 1" , class = " A" })
569575 luaunit .assertEquals ({
570- child :to_xml (),
571- document :to_xml (),
576+ normalize_attributes_order ( child :to_xml () ),
577+ normalize_attributes_order ( document :to_xml () ),
572578 },
573579 {
574580 [[ <new-child id="1" class="A"/>]] ,
@@ -597,8 +603,8 @@ function TestElement.test_insert_element_with_namespace()
597603 " xhtml:new-child" ,
598604 {id = " 1" , class = " A" })
599605 luaunit .assertEquals ({
600- child :to_xml (),
601- document :to_xml (),
606+ normalize_attributes_order ( child :to_xml () ),
607+ normalize_attributes_order ( document :to_xml () ),
602608 },
603609 {
604610 [[ <xhtml:new-child id="1" class="A"/>]] ,
0 commit comments