Remove an undefined attribute instead of setting it to "undefined" (string)

pull/1668/head
Christian Kaisermann 6 years ago
parent 9eec6f8c72
commit 790f2b5313

@ -82,7 +82,8 @@ export function removeListener(node, event, handler) {
}
export function setAttribute(node, attribute, value) {
node.setAttribute(attribute, value);
if (value === undefined) removeAttribute(node, attribute);
else node.setAttribute(attribute, value);
}
export function setAttributes(node, attributes) {
@ -90,8 +91,7 @@ export function setAttributes(node, attributes) {
if (key in node) {
node[key] = attributes[key];
} else {
if (attributes[key] === undefined) removeAttribute(node, key);
else setAttribute(node, key, attributes[key]);
setAttribute(node, key, attributes[key]);
}
}
}
@ -238,4 +238,4 @@ export function addResizeListener(element, fn) {
element.removeChild(object);
}
};
}
}

@ -0,0 +1,5 @@
export default {
'skip-ssr': true,
html: '<div></div>'
};

@ -0,0 +1,14 @@
<div {foo} {bar}></div>
<script>
export default {
data: () => ({
foo: 1,
bar: undefined
}),
oncreate () {
this.set({ foo: undefined });
}
};
</script>
Loading…
Cancel
Save