Merge branch 'html-text-undefined' of https://github.com/jasondavies/d3 into 2.7.1
This commit is contained in:
Коммит
22cdb642cd
|
@ -1575,16 +1575,18 @@ d3_selectionPrototype.property = function(name, value) {
|
|||
? propertyFunction : propertyConstant));
|
||||
};
|
||||
d3_selectionPrototype.text = function(value) {
|
||||
return arguments.length < 1 ? this.node().textContent
|
||||
: (this.each(typeof value === "function"
|
||||
? function() { this.textContent = value.apply(this, arguments); }
|
||||
: function() { this.textContent = value; }));
|
||||
return arguments.length < 1
|
||||
? this.node().textContent : this.each(typeof value === "function"
|
||||
? function() { var v = value.apply(this, arguments); this.textContent = v == null ? "" : v; } : value == null
|
||||
? function() { this.textContent = ""; }
|
||||
: function() { this.textContent = value; });
|
||||
};
|
||||
d3_selectionPrototype.html = function(value) {
|
||||
return arguments.length < 1 ? this.node().innerHTML
|
||||
: (this.each(typeof value === "function"
|
||||
? function() { this.innerHTML = value.apply(this, arguments); }
|
||||
: function() { this.innerHTML = value; }));
|
||||
return arguments.length < 1
|
||||
? this.node().innerHTML : this.each(typeof value === "function"
|
||||
? function() { var v = value.apply(this, arguments); this.innerHTML = v == null ? "" : v; } : value == null
|
||||
? function() { this.innerHTML = ""; }
|
||||
: function() { this.innerHTML = value; });
|
||||
};
|
||||
// TODO append(node)?
|
||||
// TODO append(function)?
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,6 +1,7 @@
|
|||
d3_selectionPrototype.html = function(value) {
|
||||
return arguments.length < 1 ? this.node().innerHTML
|
||||
: (this.each(typeof value === "function"
|
||||
? function() { this.innerHTML = value.apply(this, arguments); }
|
||||
: function() { this.innerHTML = value; }));
|
||||
return arguments.length < 1
|
||||
? this.node().innerHTML : this.each(typeof value === "function"
|
||||
? function() { var v = value.apply(this, arguments); this.innerHTML = v == null ? "" : v; } : value == null
|
||||
? function() { this.innerHTML = ""; }
|
||||
: function() { this.innerHTML = value; });
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
d3_selectionPrototype.text = function(value) {
|
||||
return arguments.length < 1 ? this.node().textContent
|
||||
: (this.each(typeof value === "function"
|
||||
? function() { this.textContent = value.apply(this, arguments); }
|
||||
: function() { this.textContent = value; }));
|
||||
return arguments.length < 1
|
||||
? this.node().textContent : this.each(typeof value === "function"
|
||||
? function() { var v = value.apply(this, arguments); this.textContent = v == null ? "" : v; } : value == null
|
||||
? function() { this.textContent = ""; }
|
||||
: function() { this.textContent = value; });
|
||||
};
|
||||
|
|
|
@ -28,24 +28,36 @@ suite.addBatch({
|
|||
assert.equal(document.body.lastChild.tagName, "I");
|
||||
assert.equal(document.body.lastChild.textContent, "0");
|
||||
},
|
||||
/*
|
||||
https://github.com/tmpvar/jsdom/issues/276
|
||||
"clears the inner HTML as null": function(body) {
|
||||
body.html(null);
|
||||
assert.equal(document.body.innerHTML, "");
|
||||
assert.isNull(document.body.firstChild);
|
||||
},
|
||||
*/
|
||||
"clears the inner HTML as undefined": function(body) {
|
||||
body.html(undefined);
|
||||
assert.equal(document.body.innerHTML, "");
|
||||
assert.isNull(document.body.firstChild);
|
||||
},
|
||||
"clears the inner HTML as the empty string": function(body) {
|
||||
body.html("");
|
||||
assert.equal(document.body.innerHTML, "");
|
||||
assert.isNull(document.body.firstChild);
|
||||
},
|
||||
"clears the inner HTML as a function": function(body) {
|
||||
"clears the inner HTML as a function returning the empty string": function(body) {
|
||||
body.text(function() { return ""; });
|
||||
assert.equal(document.body.innerHTML, "");
|
||||
assert.isNull(document.body.firstChild);
|
||||
},
|
||||
"clears the inner HTML as a function returning null": function(body) {
|
||||
body.text(function() { return null; });
|
||||
assert.equal(document.body.innerHTML, "");
|
||||
assert.isNull(document.body.firstChild);
|
||||
},
|
||||
"clears the inner HTML as a function returning undefined": function(body) {
|
||||
body.text(function() { return undefined; });
|
||||
assert.equal(document.body.innerHTML, "");
|
||||
assert.isNull(document.body.firstChild);
|
||||
},
|
||||
"ignores null nodes": function() {
|
||||
var body = d3.select("body");
|
||||
body[0][0] = null;
|
||||
|
|
|
@ -28,16 +28,23 @@ suite.addBatch({
|
|||
assert.equal(document.body.textContent, "<h1>Hello, world!</h1>");
|
||||
assert.equal(document.body.firstChild.nodeType, document.TEXT_NODE);
|
||||
},
|
||||
/*
|
||||
https://github.com/tmpvar/jsdom/issues/276
|
||||
/* <https://github.com/tmpvar/jsdom/issues/276>
|
||||
"clears the text content as null": function(body) {
|
||||
body.text(null);
|
||||
assert.equal(document.body.textContent, "");
|
||||
},
|
||||
"clears the text content as a function": function(body) {
|
||||
"clears the text content as undefined": function(body) {
|
||||
body.text(undefined);
|
||||
assert.equal(document.body.textContent, "");
|
||||
},
|
||||
"clears the text content as a function returning null": function(body) {
|
||||
body.text(function() { return null; });
|
||||
assert.equal(document.body.textContent, "");
|
||||
},
|
||||
"clears the text content as a function returning undefined": function(body) {
|
||||
body.text(function() { return undefined; });
|
||||
assert.equal(document.body.textContent, "");
|
||||
},
|
||||
*/
|
||||
"ignores null nodes": function() {
|
||||
var body = d3.select("body");
|
||||
|
|
Загрузка…
Ссылка в новой задаче