fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build: don't strip 'use strict'
[fnpeditor.git]
/
src
/
smartxml
/
smartxml.js
diff --git
a/src/smartxml/smartxml.js
b/src/smartxml/smartxml.js
index
52236b6
..
d42dcbf
100644
(file)
--- a/
src/smartxml/smartxml.js
+++ b/
src/smartxml/smartxml.js
@@
-268,17
+268,25
@@
$.extend(Document.prototype, Backbone.Events, {
createDocumentNode: function(from) {
if(!(from instanceof Node)) {
createDocumentNode: function(from) {
if(!(from instanceof Node)) {
- if(
from.text !== undefined
) {
- /* globals document */
-
from = document.createTextNode(from.text
);
+ if(
typeof from === 'string'
) {
+ from = parseXML(from);
+
this.normalizeXML(from
);
} else {
} else {
- var node = $('<' + from.tagName + '>');
+ if(from.text !== undefined) {
+ /* globals document */
+ from = document.createTextNode(from.text);
+ } else {
+ if(!from.tagName) {
+ throw new Error('tagName missing');
+ }
+ var node = $('<' + from.tagName + '>');
- _.keys(from.attrs || {}).forEach(function(key) {
- node.attr(key, from.attrs[key]);
- });
+
_.keys(from.attrs || {}).forEach(function(key) {
+
node.attr(key, from.attrs[key]);
+
});
- from = node[0];
+ from = node[0];
+ }
}
}
var Factory, typeMethods, typeTransformations;
}
}
var Factory, typeMethods, typeTransformations;
@@
-309,11
+317,16
@@
$.extend(Document.prototype, Backbone.Events, {
loadXML: function(xml, options) {
options = options || {};
this._defineDocumentProperties($(parseXML(xml)));
loadXML: function(xml, options) {
options = options || {};
this._defineDocumentProperties($(parseXML(xml)));
+ this.normalizeXML(this.dom);
if(!options.silent) {
this.trigger('contentSet');
}
},
if(!options.silent) {
this.trigger('contentSet');
}
},
+ normalizeXML: function(nativeNode) {
+ void(nativeNode); // noop
+ },
+
toXML: function() {
return this.root.toXML();
},
toXML: function() {
return this.root.toXML();
},
@@
-499,8
+512,10
@@
$.extend(Document.prototype, Backbone.Events, {
throw new Error('End of transaction requested, but there is no transaction in progress!');
}
this._transactionInProgress = false;
throw new Error('End of transaction requested, but there is no transaction in progress!');
}
this._transactionInProgress = false;
- this.undoStack.push(this._transactionStack);
- this._transactionStack = [];
+ if(this._transactionStack.length) {
+ this.undoStack.push(this._transactionStack);
+ this._transactionStack = [];
+ }
},
getNodeByPath: function(path) {
},
getNodeByPath: function(path) {