nodeParent,
returned;
options = options || {};
- if(!(this.document.containsNode(this))) {
+ if(!(this.document.containsNode(this)) || !insertion.isNew) {
nodeParent = insertion.ofNode.parent();
}
returned = implementation.call(this, insertion.ofNode);
var node = (metaData && metaData.node) ? metaData.node : this,
event = new events.ChangeEvent(type, $.extend({node: node}, metaData || {}));
if(type === 'nodeDetached' || this.document.containsNode(event.meta.node)) {
+ if(type === 'nodeMoved') {
+ event.meta.parent = origParent;
+ }
this.document.trigger('change', event);
}
if((type === 'nodeAdded' || type === 'nodeMoved') && !this.document.containsNode(this) && nodeWasContained) {
expect(spy.callCount).to.equal(1);
expect(event.type).to.equal('nodeMoved');
expect(event.meta.node.sameNode(appended)).to.be.true;
+ expect(node.document.root.sameNode(event.meta.parent)).to.equal(true, 'previous parent attached to event meta');
});
it('emits nodeAdded event when prepending new node', function() {