From 3b0a39df2e007f33b027b665f0f42604aecfc8b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 24 Oct 2013 10:38:28 +0200 Subject: [PATCH 1/1] smartxml: setting text on text node --- src/smartxml/smartxml.js | 4 ++++ src/smartxml/smartxml.test.js | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index b81b0f0..53eefed 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -209,6 +209,10 @@ $.extend(TextNode.prototype, DocumentNode.prototype, { return this.nativeNode.data; }, + setText: function(text) { + this.nativeNode.data = text; + }, + appendText: function(text) { this.nativeNode.data = this.nativeNode.data + text; }, diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index 2ccfa6d..b33ef1f 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -158,6 +158,16 @@ describe('smartxml', function() { }); }); + describe('Basic TextNode properties', function() { + it('can have its text set', function() { + var node = elementNodeFromXML('
Alice
'), + textNode = node.contents()[0]; + + textNode.setText('Cat'); + expect(textNode.getText()).to.equal('Cat'); + }); + }); + describe('Manipulations', function() { it('appends element node to another element node', function() { -- 2.20.1