[Pkg-javascript-commits] [dojo] 80/149: fixes #18703, treat numbers as strings for setting html content

David Prévot taffit at moszumanska.debian.org
Sat Feb 27 03:13:50 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository dojo.

commit 1b18e243c87a98fcc0eadfc72df55329b831156e
Author: Will Griffin <willgriffin at gmail.com>
Date:   Fri Sep 11 20:04:00 2015 -0700

    fixes #18703, treat numbers as strings for setting html content
---
 html.js            | 9 +++++++++
 tests/unit/html.js | 7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/html.js b/html.js
index 9f09672..f5cf90a 100644
--- a/html.js
+++ b/html.js
@@ -40,6 +40,9 @@ define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/declare", ".
 			domConstruct.empty(node);
 
 			if(cont){
+				if(typeof cont == "number"){
+					cont = cont.toString();
+				}
 				if(typeof cont == "string"){
 					cont = domConstruct.toDom(cont, node.ownerDocument);
 				}
@@ -127,6 +130,9 @@ define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/declare", ".
 				if(undefined !== cont){
 					this.content = cont;
 				}
+				if(typeof cont == 'number'){
+					cont = cont.toString();
+				}
 				// in the re-use scenario, set needs to be able to mixin new configuration
 				if(params){
 					this._mixin(params);
@@ -350,6 +356,9 @@ define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/declare", ".
 				console.warn("dojo.html.set: no cont argument provided, using empty string");
 				cont = "";
 			}
+			if (typeof cont == 'number'){
+				cont = cont.toString();
+			}
 			if(!params){
 				// simple and fast
 				return html._setNodeContent(node, cont, true);
diff --git a/tests/unit/html.js b/tests/unit/html.js
index a97f632..493b111 100644
--- a/tests/unit/html.js
+++ b/tests/unit/html.js
@@ -73,6 +73,13 @@ define([
 					testHtmlSet(container, markup);
 				},
 
+				'numeric value': function () {
+					var markup = 1.618;
+
+					html.set(container, markup);
+					assert.strictEqual(container.innerHTML, markup.toString());
+				},
+
 				'attach onEnd handler': function () {
 					var msg = 'expected';
 					var handler = sinon.stub();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list