Permalink
Browse files

#478 Element#text() fix for FF in case of empty content

  • Loading branch information...
MadRabbit committed Mar 15, 2012
1 parent dfe0cad commit 2194cb50f4734ba8ab5c70935e577293d17ff60f
Showing with 8 additions and 2 deletions.
  1. +3 −2 src/dom/element/structs.js
  2. +5 −0 test/unit/dom/element/structs_test.js
@@ -176,8 +176,9 @@ Element.include({
* @return String text content or Element this
*/
text: function(text) {
- return text === undefined ? (this._.textContent || this._.innerText) :
- this.update(this.doc()._.createTextNode(text));
+ return text === undefined ? (
+ this._.textContent === undefined ? this._.innerText : this._.textContent
+ ) : this.update(this.doc()._.createTextNode(text));
},
/**
@@ -515,6 +515,11 @@ var ElementStructsTest = TestCase.create({
this.assertEqual('Beevis & Butthead', this.el.text());
},
+ testText_getter_emptyCase: function() {
+ this.el._.innerHTML = "";
+ this.assertEqual('', this.el.text());
+ },
+
testText_setter: function() {
this.assertSame(this.el, this.el.text('<li>boo hoo!</li>'));
this.assertEqual('&lt;li&gt;boo hoo!&lt;/li&gt;', this.el._.innerHTML);

0 comments on commit 2194cb5

Please sign in to comment.