|
|
@@ -118,7 +118,15 @@ this.serializer = this.serializer || (() => {
|
|
|
if (name == "class") {
|
|
|
value = Array.from(element.classList).map(className => className.trim()).join(" ");
|
|
|
}
|
|
|
- value = value.replace(/&/g, "&").replace(/\u00a0/g, " ").replace(/"/g, """);
|
|
|
+ let simpleQuotesValue;
|
|
|
+ value = value.replace(/&/g, "&").replace(/\u00a0/g, " ");
|
|
|
+ if (value.includes("\"")) {
|
|
|
+ if (value.includes("'")) {
|
|
|
+ value = value.replace(/"/g, """);
|
|
|
+ } else {
|
|
|
+ simpleQuotesValue = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
const invalidUnquotedValue = !value.match(/^[^ \t\n\f\r'"`=<>]+$/);
|
|
|
content += " ";
|
|
|
if (!attribute.namespace) {
|
|
|
@@ -138,11 +146,11 @@ this.serializer = this.serializer || (() => {
|
|
|
if (value != "") {
|
|
|
content += "=";
|
|
|
if (invalidUnquotedValue) {
|
|
|
- content += "\"";
|
|
|
+ content += simpleQuotesValue ? "'" : "\"";
|
|
|
}
|
|
|
content += value;
|
|
|
if (invalidUnquotedValue) {
|
|
|
- content += "\"";
|
|
|
+ content += simpleQuotesValue ? "'" : "\"";
|
|
|
}
|
|
|
}
|
|
|
}
|