Highcharts将重复的xmlns属性添加到IE中的SVG元素 [英] Highcharts adds duplicate xmlns attribute to SVG element in IE

查看:127
本文介绍了Highcharts将重复的xmlns属性添加到IE中的SVG元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Highcharts在PHP Web应用程序中创建图表。问题在于,在IE中,创建的SVG元素最终具有重复的xmlns属性。可以在F12开发者工具HTML标签中看到:

I'm using Highcharts to create charts in a PHP web application. Problem is that in IE, the SVG element that is created ends up with duplicate xmlns attributes. It can be seen in the F12 developer tools, HTML tab:


(点击查看更大的版本)

虽然图表在浏览器中显示得很好,但试图将其转换为带蜡染的图像文件时会产生问题,该图像抱怨关于重复的属性。

While the chart displays just fine in the browser, it causes a problem when trying to convert it to an image file with Batik, which complains about the duplicate attribute.

我已经在IE 9和10中再现了这一点,并且还在highcharts.com上显示了演示图表(上图是拍摄)。但是,Firefox不会发生这种情况。

I've reproduced this in both IE 9 and 10, and also with the demo charts at highcharts.com (which is where the above screenshot was taken). It doesn't happen with Firefox, though.

如何防止重复属性?或者,删除它的最佳方法是什么(PHP或jQuery)?我尝试过通过Tidy运行包含SVG的HTML,但是最终将 clipPath 等元素转换为小写字母,这会导致它自己的问题。

How do I prevent the duplicate attribute? Or alternatively, what's the best way to remove it (PHP or jQuery)? I've tried running the HTML containing the SVG through Tidy, but that ends up converting elements like clipPath to lowercase, which causes problems of its own.

推荐答案

现在我们修复了这个bug,请参阅 https://github.com/highslide-software/highcharts.com/issues/1978 。虽然元素是使用 createElementNS 创建的,但只有IE9和IE10为它创建了一个可见属性。所以解决方法是添加属性,如果不存在。

We fixed the bug now, see the the linked code at https://github.com/highslide-software/highcharts.com/issues/1978. While the element was created with createElementNS, only IE9 and IE10 actually created a visible attribute for it. So the workaround was to add the attribute as well if not present.

这篇关于Highcharts将重复的xmlns属性添加到IE中的SVG元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆