klaro-org / klaro-js

Klaro Privacy Manager. An open-source, privacy-friendly & compliant consent manager for your website.
https://klaro.org
Other
1.17k stars 249 forks source link

<svg><script></script></svg> is causing Uncaught TypeError: r.src is undefined when library is aggregated #488

Open sascha-meissner opened 7 months ago

sascha-meissner commented 7 months ago

I´m getting error Uncaught TypeError: r.src

when having

<svg><script></script></svg>

within my html and aggregate the klaro library with other js libraries (Drupal javascript aggregation)

The error can be supressed by checking for existence of src attribute in: https://github.com/klaro-org/privacy-manager/blob/d2f8418ede6b7706090fd0d746a5bb0046772d45/src/utils/compat.js#L9

e.g script.src && script.src.includes(name)

This issue might be somehow related to https://github.com/klaro-org/privacy-manager/issues/273 But i´m having this error in every browser i tested (Firefox, Chrome) not only in IE11

And yes, the problem is that klaro library is not in its own script tag but bundled with other js files in a single script tag, thats why it cannot determine which is the "currentScript", it still might be worth to check for the src attribute as it will also fail if theres a script tag with a body/ without src attribute occuring before the klaro script