X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/f748267f6e177cba7cb4a91439e6fff037cb1d9c..0f406b246f9261651b5982be71a49189349c8e3e:/modules/documentCanvas/tests/utils.js diff --git a/modules/documentCanvas/tests/utils.js b/modules/documentCanvas/tests/utils.js new file mode 100644 index 0000000..e23808c --- /dev/null +++ b/modules/documentCanvas/tests/utils.js @@ -0,0 +1,29 @@ +define(['libs/jquery-1.9.1.min'], function($) { + return { + cleanUp: function(xml) { + + var rmws = function(node) { + if(node.nodeType === 3) { + node.data = $.trim(node.data); + } + else { + $(node).contents().each(function() { + rmws(this); + }); + } + } + + xml = $($.trim(xml)); + xml.each(function() { + rmws(this); + }); + + /*var toret = xml + .replace(/(<.*>)\s*(<.*>)/gm, '$1$2') + .replace(/(<\/.*>)\s*(<\/.*>)/gm, '$1$2') + .replace(/(<\/.*>)\s*(<.*>)/gm, '$1$2'); + return $.trim(toret);*/ + return $('
').append(xml).html(); + } + } +}); \ No newline at end of file