Safari does not support the solution of the SVG innerHTML method

Source: Internet
Author: User

Because the low-version Safari browser does not support the innerHTML method under SVG

And our mobile H5 page references the D3.js plugin, and D3 uses the innerHTML

Our solution is not to modify any of D3 's original code, to rewrite the innerHTML method

A small plugin was found on GitHub and can be easily modified to achieve

Https://github.com/phaistonian/SVGInnerHTML

We have modified the content to have these:

Modification 1: Increase the processing of the text node
constructors = [' svgsvgelement ', ' svgtextelement ']

Change 2: Add a separate write to the text
fn = function (to, node) {
Text
 if (Node.nodetype = = 3) {
To.appendchild (node);
Return
}

Modification 3: Text writing and Tspan when commenting out
/*if (Node.nodename = = = ' TEXT ' | | node.nodename = = = ' Tspan ') {
Newnode.textcontent = node.innerhtml;
}*/

Safari does not support the solution of the SVG innerHTML method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.