From c0e7047acad747fa666c562ed4b0dda481b7325e Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Mon, 20 Aug 2018 23:02:24 -0300 Subject: [PATCH] Also check for null-valued attributes --- src/shared/dom.js | 2 +- .../samples/dont-use-dataset-in-legacy/expected-bundle.js | 7 ++++++- test/js/samples/dont-use-dataset-in-svg/expected-bundle.js | 7 ++++++- test/js/samples/input-files/expected-bundle.js | 7 ++++++- test/js/samples/input-range/expected-bundle.js | 7 ++++++- .../input-without-blowback-guard/expected-bundle.js | 7 ++++++- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/shared/dom.js b/src/shared/dom.js index 5e152b9c1b..51281409a7 100644 --- a/src/shared/dom.js +++ b/src/shared/dom.js @@ -82,7 +82,7 @@ export function removeListener(node, event, handler) { } export function setAttribute(node, attribute, value) { - if (value === undefined) removeAttribute(node, attribute); + if (value == null) removeAttribute(node, attribute); else node.setAttribute(attribute, value); } diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js index 30890b83a3..9ca1b19266 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js @@ -22,7 +22,12 @@ function createText(data) { } function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); + if (value == null) removeAttribute(node, attribute); + else node.setAttribute(attribute, value); +} + +function removeAttribute(node, attribute) { + node.removeAttribute(attribute); } function blankObject() { diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js index 9c006e2870..4192676418 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js @@ -22,7 +22,12 @@ function createSvgElement(name) { } function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); + if (value == null) removeAttribute(node, attribute); + else node.setAttribute(attribute, value); +} + +function removeAttribute(node, attribute) { + node.removeAttribute(attribute); } function blankObject() { diff --git a/test/js/samples/input-files/expected-bundle.js b/test/js/samples/input-files/expected-bundle.js index 1a6376f193..4e51694625 100644 --- a/test/js/samples/input-files/expected-bundle.js +++ b/test/js/samples/input-files/expected-bundle.js @@ -26,7 +26,12 @@ function removeListener(node, event, handler) { } function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); + if (value == null) removeAttribute(node, attribute); + else node.setAttribute(attribute, value); +} + +function removeAttribute(node, attribute) { + node.removeAttribute(attribute); } function blankObject() { diff --git a/test/js/samples/input-range/expected-bundle.js b/test/js/samples/input-range/expected-bundle.js index f9b53e91a5..1711ee53bb 100644 --- a/test/js/samples/input-range/expected-bundle.js +++ b/test/js/samples/input-range/expected-bundle.js @@ -26,7 +26,12 @@ function removeListener(node, event, handler) { } function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); + if (value == null) removeAttribute(node, attribute); + else node.setAttribute(attribute, value); +} + +function removeAttribute(node, attribute) { + node.removeAttribute(attribute); } function toNumber(value) { diff --git a/test/js/samples/input-without-blowback-guard/expected-bundle.js b/test/js/samples/input-without-blowback-guard/expected-bundle.js index c3abad14fe..817aa1e401 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -26,7 +26,12 @@ function removeListener(node, event, handler) { } function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); + if (value == null) removeAttribute(node, attribute); + else node.setAttribute(attribute, value); +} + +function removeAttribute(node, attribute) { + node.removeAttribute(attribute); } function blankObject() {