Skip to content

Commit 6ae4891

Browse files
committed
return empty string when attribute value is not string type
1 parent b32f87a commit 6ae4891

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/js2xml.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ function escapeSingleQuotes (value) {
1212

1313
function stringifyAttribute (attrs, key, keepDoubleQuotes) {
1414
const value = attrs[key]
15+
if (typeof value !== 'string') {
16+
console.error('invalid attribute type:', attrs, key)
17+
return `${key}=''`
18+
}
1519
try {
1620
if (keepDoubleQuotes) {
1721
return `${key}='${escapeSingleQuotes(value)}'`

0 commit comments

Comments
 (0)