X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/fb23a597811c4c60dd1b9bddeab4335a33bee8c1..59f806bb8a3b304b1c1293d8634bcf38bcd31332:/src/smartxml/smartxml.js diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index f92bf01..acbe04d 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -222,7 +222,12 @@ $.extend(TextNode.prototype, { var parseXML = function(xml) { - return $($.trim(xml))[0]; + var toret = $($.trim(xml)); + if(!toret.length) { + throw new Error('Unable to parse XML: ' + xml); + } + return toret[0]; + }; var registerTransformation = function(desc, name, target) { @@ -276,6 +281,9 @@ $.extend(Document.prototype, Backbone.Events, { /* 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) {