adobe-webplatform / Snap.svg

The JavaScript library for modern SVG graphics.
http://snapsvg.io
Apache License 2.0
13.91k stars 1.15k forks source link

Upgrading targetSDK causes issues loading SVG #663

Closed jtellezvs closed 2 years ago

jtellezvs commented 2 years ago

Version info:

Android targetSDK 30(Android 11) SnapSVG 0.4.1/0.5.1

After migrating the project to targetSDK 30, a WebView that hosts an SVG file is unable to load and remains blank. The logs are showing an issue reading fragment.node.attributes.viewBox.value which is an attribute that is made available on the root svg node. The SVG element is also not available from the fragment.select('svg') call which also worked before the update.

 if ((undefined !== fragment) && (null !== fragment)) {
                var element = fragment.select('svg'),
                    p,
                    t;

                // Save Map attributes
                if (null !== element) {
                    // #SVG2
                    Map.settings.docViewBox = element.attr('viewBox');
                } else {
                    // #SVG
                    Map.settings.docViewBox = fragment.node.attributes.viewBox.value;
                }

script.js:25 Uncaught TypeError: Cannot read properties of undefined (reading 'viewBox')

<svg preserveAspectRatio="xMinYMin" viewBox="0 0 481.75 402.39999"

I didn't see anything mentioned in other issues or documentation, but has the way we are to access these variables changed?

ibrierley commented 2 years ago

It's probably not your issue, but I would firstly try 0.5.2 (I think thats the dev branch iirc) as 0.5.1 had some oddities.

jtellezvs commented 2 years ago

Thanks, I will give that shot. I am using a minified version that I package into the app. Is there a place where I can download version 0.5.2?