child = root.children()[1];
expect(root.childIndex(child)).to.equal(1);
});
+
+ describe('DocumentTextElement can have its content set', function() {
+ var c = canvas.fromXML('<section>Alice</section>'),
+ root = c.doc(),
+ text = root.children()[0];
+
+ text.setText('a cat');
+ expect(root.children()[0].getText()).to.equal('a cat');
+ });
});
});
return dom;
};
+$.extend(DocumentTextElement.prototype, {
+ setText: function(text) {
+ this.$element[0].data = text;
+ },
+ getText: function() {
+ return this.$element.text();
+ }
+});
+
var documentElementFromHTMLElement = function(htmlElement) {
if(htmlElement.nodeType === Node.ELEMENT_NODE)
return new DocumentNodeElement(htmlElement);