summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a849d47)
Document instance's reference to the root wasn't being cleared
this._$.detach();
if(existed) {
this.triggerChangeEvent('nodeDetached', {parent: parent});
this._$.detach();
if(existed) {
this.triggerChangeEvent('nodeDetached', {parent: parent});
+ if(!parent) {
+ // This was the root of the document
+ this.document._defineDocumentProperties(null);
+ }
_defineDocumentProperties: function($document) {
var doc = this;
Object.defineProperty(doc, 'root', {get: function() {
_defineDocumentProperties: function($document) {
var doc = this;
Object.defineProperty(doc, 'root', {get: function() {
+ if(!$document) {
+ return null;
+ }
return doc.createDocumentNode($document[0]);
}, configurable: true});
Object.defineProperty(doc, 'dom', {get: function() {
return doc.createDocumentNode($document[0]);
}, configurable: true});
Object.defineProperty(doc, 'dom', {get: function() {
+ if(!$document) {
+ return null;
+ }
return $document[0];
}, configurable: true});
}
return $document[0];
}, configurable: true});
}
describe('Manipulations', function() {
describe('Manipulations', function() {
+ describe('detaching nodes', function() {
+ it('can detach document root node', function() {
+ var doc = getDocumentFromXML('<div></div>');
+
+ doc.root.detach();
+ expect(doc.root).to.equal(null);
+ });
+ });
+
describe('replacing node with another one', function() {
it('replaces node with another one', function() {
var doc = getDocumentFromXML('<div><a></a></div>'),
describe('replacing node with another one', function() {
it('replaces node with another one', function() {
var doc = getDocumentFromXML('<div><a></a></div>'),