Skip to content

Commit 790f2b5

Browse files
committed
Remove an undefined attribute instead of setting it to "undefined" (string)
1 parent 9eec6f8 commit 790f2b5

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/shared/dom.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ export function removeListener(node, event, handler) {
8282
}
8383

8484
export function setAttribute(node, attribute, value) {
85-
node.setAttribute(attribute, value);
85+
if (value === undefined) removeAttribute(node, attribute);
86+
else node.setAttribute(attribute, value);
8687
}
8788

8889
export function setAttributes(node, attributes) {
8990
for (var key in attributes) {
9091
if (key in node) {
9192
node[key] = attributes[key];
9293
} else {
93-
if (attributes[key] === undefined) removeAttribute(node, key);
94-
else setAttribute(node, key, attributes[key]);
94+
setAttribute(node, key, attributes[key]);
9595
}
9696
}
9797
}
@@ -238,4 +238,4 @@ export function addResizeListener(element, fn) {
238238
element.removeChild(object);
239239
}
240240
};
241-
}
241+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
'skip-ssr': true,
3+
4+
html: '<div></div>'
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div {foo} {bar}></div>
2+
3+
<script>
4+
export default {
5+
data: () => ({
6+
foo: 1,
7+
bar: undefined
8+
}),
9+
10+
oncreate () {
11+
this.set({ foo: undefined });
12+
}
13+
};
14+
</script>

0 commit comments

Comments
 (0)