setText: function(text) {
this.nativeNode.data = text;
+ this.triggerTextChangeEvent();
},
appendText: function(text) {
this.nativeNode.data = this.nativeNode.data + text;
+ this.triggerTextChangeEvent();
},
prependText: function(text) {
this.nativeNode.data = text + this.nativeNode.data;
+ this.triggerTextChangeEvent();
+ },
+
+ triggerTextChangeEvent: function() {
+ var event = new events.ChangeEvent('nodeTextChange', {node: this});
+ this.document.trigger('change', event);
}
});
textNode.setText('Cat');
expect(textNode.getText()).to.equal('Cat');
});
+
+ it('emits nodeTextChange', function() {
+ var node = elementNodeFromXML('<div>Alice</div>'),
+ textNode = node.contents()[0],
+ spy = sinon.spy();
+
+ textNode.document.on('change', spy);
+ textNode.setText('Cat');
+
+ var event = spy.args[0][0];
+ expect(event.type).to.equal('nodeTextChange');
+ });
});
describe('Manipulations', function() {