Skip to content

Commit 89c1fa6

Browse files
committed
Also check for null-valued attributes
1 parent 790f2b5 commit 89c1fa6

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

src/shared/dom.js

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

8484
export function setAttribute(node, attribute, value) {
85-
if (value === undefined) removeAttribute(node, attribute);
85+
if (value == null) removeAttribute(node, attribute);
8686
else node.setAttribute(attribute, value);
8787
}
8888

test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ function createText(data) {
2222
}
2323

2424
function setAttribute(node, attribute, value) {
25-
node.setAttribute(attribute, value);
25+
if (value == null) removeAttribute(node, attribute);
26+
else node.setAttribute(attribute, value);
27+
}
28+
29+
function removeAttribute(node, attribute) {
30+
node.removeAttribute(attribute);
2631
}
2732

2833
function blankObject() {

test/js/samples/dont-use-dataset-in-svg/expected-bundle.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ function createSvgElement(name) {
2222
}
2323

2424
function setAttribute(node, attribute, value) {
25-
node.setAttribute(attribute, value);
25+
if (value == null) removeAttribute(node, attribute);
26+
else node.setAttribute(attribute, value);
27+
}
28+
29+
function removeAttribute(node, attribute) {
30+
node.removeAttribute(attribute);
2631
}
2732

2833
function blankObject() {

test/js/samples/input-files/expected-bundle.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ function removeListener(node, event, handler) {
2626
}
2727

2828
function setAttribute(node, attribute, value) {
29-
node.setAttribute(attribute, value);
29+
if (value == null) removeAttribute(node, attribute);
30+
else node.setAttribute(attribute, value);
31+
}
32+
33+
function removeAttribute(node, attribute) {
34+
node.removeAttribute(attribute);
3035
}
3136

3237
function blankObject() {

test/js/samples/input-range/expected-bundle.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ function removeListener(node, event, handler) {
2626
}
2727

2828
function setAttribute(node, attribute, value) {
29-
node.setAttribute(attribute, value);
29+
if (value == null) removeAttribute(node, attribute);
30+
else node.setAttribute(attribute, value);
31+
}
32+
33+
function removeAttribute(node, attribute) {
34+
node.removeAttribute(attribute);
3035
}
3136

3237
function toNumber(value) {

test/js/samples/input-without-blowback-guard/expected-bundle.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ function removeListener(node, event, handler) {
2626
}
2727

2828
function setAttribute(node, attribute, value) {
29-
node.setAttribute(attribute, value);
29+
if (value == null) removeAttribute(node, attribute);
30+
else node.setAttribute(attribute, value);
31+
}
32+
33+
function removeAttribute(node, attribute) {
34+
node.removeAttribute(attribute);
3035
}
3136

3237
function blankObject() {

0 commit comments

Comments
 (0)