From 089f0616416ed96d0df783112179bb1f178a5c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=84=E6=88=90=E6=96=87?= Date: Sat, 8 Jun 2013 05:29:14 +0000 Subject: [PATCH] fix a bug in svgToString function: some elements have no attribute, so when convert it to stinrg some namespace can't be set correctly. now, the tag like this can be correctly converted: hello git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2517 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 6147f35a..45238e05 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -4120,6 +4120,13 @@ this.svgToString = function(elem, indent) { // Check elements for namespaces, add if found $(elem).find('*').andSelf().each(function() { var el = this; + // for some elements have no attribute + var uri = this.namespaceURI; + if(uri && !nsuris[uri] && nsMap[uri] && nsMap[uri] !== 'xmlns' && nsMap[uri] !== 'xml' ) { + nsuris[uri] = true; + out.push(" xmlns:" + nsMap[uri] + '="' + uri +'"'); + } + $.each(this.attributes, function(i, attr) { var uri = attr.namespaceURI; if (uri && !nsuris[uri] && nsMap[uri] !== 'xmlns' && nsMap[uri] !== 'xml' ) {