diff --git a/src/printer.js b/src/printer.js index 3e227f6..6fcff86 100644 --- a/src/printer.js +++ b/src/printer.js @@ -428,7 +428,7 @@ function printElement(path, opts, print) { // Handle the 1 but not both being an xmlns if (leftNS === "xmlns") return -1; - if (rightNS === "xlmns") return 1; + if (rightNS === "xmlns") return 1; return leftNS.localeCompare(rightNS); } diff --git a/test/__snapshots__/format.test.js.snap b/test/__snapshots__/format.test.js.snap index 90b1f97..0047020 100644 --- a/test/__snapshots__/format.test.js.snap +++ b/test/__snapshots__/format.test.js.snap @@ -114,6 +114,8 @@ use { otherTools:baz="bing" ios:a="a" /> + + @@ -241,6 +243,8 @@ use { otherTools:baz="bing" ios:a="a"/> + + @@ -364,6 +368,8 @@ use { ios:a="a" /> + + @@ -518,6 +524,14 @@ use { ios:a="a" /> + + @@ -641,6 +655,8 @@ use { ios:a="a" /> + + @@ -764,6 +780,8 @@ use { ios:a="a" /> + + @@ -887,6 +905,8 @@ use { ios:a='a' /> + + @@ -1019,6 +1039,8 @@ use { ios:a="a" /> + + @@ -1032,6 +1054,131 @@ use { " `; +exports[`xmlSortAttributesByKey => true 1`] = ` +" + + + + + Style inheritance and the use element + + &anp; 〹 + + bar + + + + + + + + + +- 1 + - 2 +- 3 + + + + + + + + + + + + < ignored /> + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at est eget enim consectetur accumsan. Aliquam pretium sodales ipsum quis dignissim. Sed id sem vel diam luctus fringilla. Aliquam quis egestas magna. Curabitur molestie lorem et odio porta, et molestie libero laoreet. Morbi rhoncus sagittis cursus. Nullam vehicula pretium consequat. Praesent porta ante at posuere sollicitudin. Nullam commodo tempor arcu, at condimentum neque elementum ut. + + + content + + + text with space + + + even more + + + + + + + + + + + + + + + + + + + + + + + + He said, "Don't quote me." + + + + + + +" +`; + exports[`xmlWhitespaceSensitivity => ignore 1`] = ` " + + @@ -1276,6 +1425,8 @@ use { ios:a="a" /> + + diff --git a/test/fixture.xml b/test/fixture.xml index 8f2142c..2c52525 100644 --- a/test/fixture.xml +++ b/test/fixture.xml @@ -94,6 +94,8 @@ otherTools:baz="bing" ios:a="a" /> + + diff --git a/test/format.test.js b/test/format.test.js index ebaa16d..5448dc2 100644 --- a/test/format.test.js +++ b/test/format.test.js @@ -24,6 +24,7 @@ test("xmlWhitespaceSensitivity => ignore", async () => { const formatted = await format(fixture, { xmlWhitespaceSensitivity: "ignore" }); + expect(formatted).toMatchSnapshot(); }); @@ -76,6 +77,8 @@ test("xmlSortAttributesByKey => true", async () => { const formatted = await format(fixture, { xmlSortAttributesByKey: true }); + + expect(formatted).toMatchSnapshot(); }); test("xmlQuoteAttributes => preserve", async () => {
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at est eget enim consectetur accumsan. Aliquam pretium sodales ipsum quis dignissim. Sed id sem vel diam luctus fringilla. Aliquam quis egestas magna. Curabitur molestie lorem et odio porta, et molestie libero laoreet. Morbi rhoncus sagittis cursus. Nullam vehicula pretium consequat. Praesent porta ante at posuere sollicitudin. Nullam commodo tempor arcu, at condimentum neque elementum ut. +