From b5ab7dfb7fe83f00df0a3b17a49027bd3a1c80dc Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Tue, 12 Jun 2018 20:11:34 +0000 Subject: [PATCH] Simplified JavaScript demo code to use textContent instead of manipulating text nodes. --- javascript/qrcodegen-demo.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/javascript/qrcodegen-demo.js b/javascript/qrcodegen-demo.js index e75e689..2712985 100644 --- a/javascript/qrcodegen-demo.js +++ b/javascript/qrcodegen-demo.js @@ -127,10 +127,7 @@ function redrawQrCode() { stats += "encoding mode = " + describeSegments(segs) + ", "; stats += "error correction = level " + "LMQH".charAt(qr.errorCorrectionLevel.ordinal) + ", "; stats += "data bits = " + qrcodegen.QrSegment.getTotalBits(segs, qr.version) + "."; - var elem = document.getElementById("statistics-output"); - while (elem.firstChild != null) - elem.removeChild(elem.firstChild); - elem.appendChild(document.createTextNode(stats)); + document.getElementById("statistics-output").textContent = stats; }