node.setData(this.getData());
if(this.sameNode(this.document.root)) {
- defineDocumentProperties(this.document, node._$);
+ this.document._defineDocumentProperties(node._$);
}
this._$.replaceWith(node._$);
this._setNativeNode(node._$[0]);
loadXML: function(xml, options) {
options = options || {};
- defineDocumentProperties(this, $(parseXML(xml)));
+ this._defineDocumentProperties($(parseXML(xml)));
if(!options.silent) {
this.trigger('contentSet');
}
toret = toret.contents()[idx];
});
return toret;
+ },
+
+ _defineDocumentProperties: function($document) {
+ var doc = this;
+ Object.defineProperty(doc, 'root', {get: function() {
+ return doc.createDocumentNode($document[0]);
+ }, configurable: true});
+ Object.defineProperty(doc, 'dom', {get: function() {
+ return $document[0];
+ }, configurable: true});
}
});
-var defineDocumentProperties = function(doc, $document) {
- Object.defineProperty(doc, 'root', {get: function() {
- return doc.createDocumentNode($document[0]);
- }, configurable: true});
- Object.defineProperty(doc, 'dom', {get: function() {
- return $document[0];
- }, configurable: true});
-};
-
return {
documentFromXML: function(xml) {