fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge in change to the Actions api
[fnpeditor.git]
/
src
/
smartxml
/
smartxml.js
diff --git
a/src/smartxml/smartxml.js
b/src/smartxml/smartxml.js
index
8039916
..
a5a1abc
100644
(file)
--- a/
src/smartxml/smartxml.js
+++ b/
src/smartxml/smartxml.js
@@
-162,10
+162,14
@@
$.extend(DocumentNode.prototype, {
},
getIndex: function() {
},
getIndex: function() {
+ var parent;
+
if(this.isRoot()) {
return 0;
}
if(this.isRoot()) {
return 0;
}
- return this.parent().indexOf(this);
+
+ parent = this.parent();
+ return parent ? parent.indexOf(this) : undefined;
},
getNearestElementNode: function() {
},
getNearestElementNode: function() {
@@
-295,7
+299,7
@@
$.extend(TextNode.prototype, {
var parseXML = function(xml) {
var toret = $($.trim(xml));
var parseXML = function(xml) {
var toret = $($.trim(xml));
- if(
!toret.length
) {
+ if(
toret.length !== 1
) {
throw new Error('Unable to parse XML: ' + xml);
}
return toret[0];
throw new Error('Unable to parse XML: ' + xml);
}
return toret[0];
@@
-574,7
+578,6
@@
$.extend(Document.prototype, Backbone.Events, fragments, {
if(transformations.length > 1) {
// In case of real transactions we don't want to run undo on all of transformations if we don't have to.
if(transformations.length > 1) {
// In case of real transactions we don't want to run undo on all of transformations if we don't have to.
- stopAt = undefined;
transformations.some(function(t, idx) {
if(!t.undo && t.getChangeRoot().sameNode(doc.root)) {
stopAt = idx;
transformations.some(function(t, idx) {
if(!t.undo && t.getChangeRoot().sameNode(doc.root)) {
stopAt = idx;
@@
-662,8
+665,11
@@
$.extend(Document.prototype, Backbone.Events, fragments, {
getNodeByPath: function(path) {
var toret = this.root;
getNodeByPath: function(path) {
var toret = this.root;
- path.
forEach
(function(idx) {
+ path.
some
(function(idx) {
toret = toret.contents()[idx];
toret = toret.contents()[idx];
+ if(!toret) {
+ return true;
+ }
});
return toret;
},
});
return toret;
},