Merge pull request #30 from progers/master

Fix icons in Safari due to a redefinition of the xmlns attribute
master
Jeff Schiller 2015-11-30 20:45:03 -08:00
commit d68c964588
1 changed files with 3 additions and 4 deletions

View File

@ -290,7 +290,9 @@ $(function() {
holder = $('#' + id);
var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0];
var svgroot = document.createElementNS(svgns, "svg");
svgroot.setAttributeNS(svgns, 'viewBox', [0,0,icon_w,icon_h].join(' '));
// Per http://www.w3.org/TR/xml-names11/#defaulting, the namespace for
// attributes should have no value.
svgroot.setAttributeNS(null, 'viewBox', [0,0,icon_w,icon_h].join(' '));
// Make flexible by converting width/height to viewBox
var w = svg.getAttribute('width');
@ -317,9 +319,6 @@ $(function() {
svgroot.appendChild(svg);
var icon;
if(toImage) {
// Without cloning, Safari will crash
// With cloning, causes issue in Opera/Win/Non-EN
var svgcontent = isOpera?svgroot:svgroot.cloneNode(true);
temp_holder.empty().append(svgroot);
var str = data_pre + encode64(unescape(encodeURIComponent(new XMLSerializer().serializeToString(svgroot))));
icon = $(new Image())