Skip to content

Commit 5ecd8ff

Browse files
committed
fix: attributes with " characters were stringifies incorrectly
Replace `"` in an attribute value with `"` so that it don't prematurely close the attribute value.
1 parent f2fb919 commit 5ecd8ff

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/stringify.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
// Based on package html-parse-stringify2
22
// Expanded to handle webcomponents
33

4-
var attrString, stringifier;
5-
6-
attrString = function (attrs) {
7-
var buff, key;
8-
buff = [];
9-
for (key in attrs) {
10-
buff.push(key + '="' + attrs[key] + '"');
4+
function attrString(attrs) {
5+
const buff = [];
6+
for (const key in attrs) {
7+
buff.push(key + '="' + attrs[key].replace(/"/g, '"') + '"');
118
}
129
if (!buff.length) {
1310
return '';
1411
}
1512
return ' ' + buff.join(' ');
1613
};
1714

18-
stringifier = function (buff, doc) {
15+
function stringifier(buff, doc) {
1916
switch (doc.type) {
2017
case 'text':
2118
return buff + doc.content;

0 commit comments

Comments
 (0)