+ return !!(otherNode) && this.nativeNode === otherNode.nativeNode;
+ },
+
+ parent: function() {
+ var parentNode = this.nativeNode.parentNode;
+ if(parentNode && parentNode.nodeType === Node.ELEMENT_NODE) {
+ return this.document.createDocumentNode(parentNode);
+ }
+ return null;
+ },
+
+ parents: function() {
+ var parent = this.parent(),
+ parents = parent ? parent.parents() : [];
+ if(parent) {
+ parents.unshift(parent);
+ }
+ return parents;
+ },
+
+ prev: function() {
+ var myIdx = this.getIndex();
+ return myIdx > 0 ? this.parent().contents()[myIdx-1] : null;
+ },
+
+ next: function() {
+ if(this.isRoot()) {
+ return null;
+ }
+ var myIdx = this.getIndex(),
+ parentContents = this.parent().contents();
+ return myIdx < parentContents.length - 1 ? parentContents[myIdx+1] : null;
+ },
+
+ isSurroundedByTextElements: function() {
+ var prev = this.prev(),
+ next = this.next();
+ return prev && (prev.nodeType === Node.TEXT_NODE) && next && (next.nodeType === Node.TEXT_NODE);
+ },
+
+ triggerChangeEvent: function(type, metaData, origParent, nodeWasContained) {
+ 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)) {
+ this.document.trigger('change', event);
+ }
+ if((type === 'nodeAdded' || type === 'nodeMoved') && !this.document.containsNode(this) && nodeWasContained) {
+ event = new events.ChangeEvent('nodeDetached', {node: node, parent: origParent});
+ this.document.trigger('change', event);
+ }
+ },
+
+ getNodeInsertion: function(node) {
+ return this.document.getNodeInsertion(node);
+ },
+
+ getIndex: function() {
+ if(this.isRoot()) {
+ return 0;
+ }
+ return this.parent().indexOf(this);