fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
smartxml: fix DocumentNode.parent
[fnpeditor.git]
/
src
/
smartxml
/
smartxml.js
diff --git
a/src/smartxml/smartxml.js
b/src/smartxml/smartxml.js
index
b469068
..
5ad3010
100644
(file)
--- a/
src/smartxml/smartxml.js
+++ b/
src/smartxml/smartxml.js
@@
-27,7
+27,9
@@
$.extend(DocumentNode.prototype, {
},
detach: function() {
},
detach: function() {
+ var parent = this.parent();
this._$.detach();
this._$.detach();
+ this.triggerChangeEvent('nodeDetached', {parent: parent});
return this;
},
return this;
},
@@
-36,7
+38,11
@@
$.extend(DocumentNode.prototype, {
},
parent: function() {
},
parent: function() {
- return this.nativeNode.parentNode ? this.document.createElementNode(this.nativeNode.parentNode) : null;
+ var parentNode = this.nativeNode.parentNode;
+ if(parentNode && parentNode.nodeType === Node.ELEMENT_NODE) {
+ return this.document.createElementNode(parentNode);
+ }
+ return null;
},
after: function(node) {
},
after: function(node) {
@@
-78,6
+84,10
@@
$.extend(DocumentNode.prototype, {
insertion.insertsNew = true;
}
return insertion;
insertion.insertsNew = true;
}
return insertion;
+ },
+
+ getIndex: function() {
+ return this.parent().indexOf(this);
}
});
}
});
@@
-315,7
+325,13
@@
$.extend(Document.prototype, Backbone.Events, {
from = node[0];
}
}
from = node[0];
}
}
- return new this.ElementNodeFactory(from, this);
+ var Factory;
+ if(from.nodeType === Node.TEXT_NODE) {
+ Factory = this.TextNodeFactory;
+ } else if(from.nodeType === Node.ELEMENT_NODE) {
+ Factory = this.ElementNodeFactory;
+ }
+ return new Factory(from, this);
},
createTextNode: function(nativeNode) {
},
createTextNode: function(nativeNode) {