svnno****@sourc*****
svnno****@sourc*****
2009年 10月 12日 (月) 19:37:47 JST
Revision: 1327 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1327 Author: dhrname Date: 2009-10-12 19:37:46 +0900 (Mon, 12 Oct 2009) Log Message: ----------- 名前空間を書いたときに、エラーとなるバグを修正 Modified Paths: -------------- trunk/svginhtml.js Modified: trunk/svginhtml.js =================================================================== --- trunk/svginhtml.js 2009-10-11 13:18:28 UTC (rev 1326) +++ trunk/svginhtml.js 2009-10-12 10:37:46 UTC (rev 1327) @@ -31,7 +31,11 @@ var sc = document.getElementsByTagName("script"), source = ""; for (var i=0;i<sc.length;++i) { if (sc[i].getAttribute("type") === "text/svg") { - source = sc[i].text.replace(/<svg([^>]*)>/g, '<script type="image/svg+xml" $1><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" $1>') + source = sc[i].text.replace(/<svg[^>]*/g, (function(s) { + s = s.replace(/xmlns(\:xlink)?=["'][^"']+?["']/g, "").replace(/<svg/, ""); + s = '<script type="image/svg+xml"' +s+ '><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +s; + return s; + })) .replace(/<\/svg>/g, "</svg></script>") .replace(/<\/(body|html)>/g, ""); } @@ -49,7 +53,11 @@ function _webkit_wo(data) { if (data.success) { var source = ""; - source = data.content.replace(/<svg([^>]*)>/g, '<script type="image/svg+xml" $1><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" $1>') + source = data.content.replace(/<svg[^>]*/g, (function(s) { + s = s.replace(/xmlns(\:xlink)?=["'][^"']+?["']/g, "").replace(/<svg/, ""); + s = '<script type="image/svg+xml"' +s+ '><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +s; + return s; + })) .replace(/<\/svg>/g, "</svg></script>") .replace(/<\/(body|html)>/g, ""); var n = source.indexOf("svginhtml.js");