fix: failed getElementById in @micro-zoe/micro-app proxy sandbox mode
since data-src is a non-standard attribute, micro-zoe/micro-app does not do anything about it during their js sandbox processing. this causes legayPolyfill to fail
So we are using @micro-zoe/micro-app (https://github.com/jd-opensource/micro-app) for our micro frontend project, and we came across this issue:
They strip the content of inline scripts and execute it in a Proxied environment, which does not have access to the original <script> tag and data-src attribute.
Submitting a fix for this problem. Also I believe this make the plugin more robust as it does not rely on a getElementById call at runtime
There is also an issue with replaceInStringLiteral function in that replacing with stringLiteral.value will unescape double quotes and the such. for example
const styleString = "@charset \"UTF-8\";cursor: url(/__vite_dynamic_public_path__/assets/cursor.svg);"
will have the raw as "@charset \"UTF-8\";cursor: url(/__vite_dynamic_public_path__/assets/cursor.svg);" and value as @charset "UTF-8";cursor: url(/__vite_dynamic_public_path__/assets/cursor.svg);
The original method would transform the output into:
const styleString = "@charset "UTF-8";cursor: url(" + window.SOMETHING + "/assets/cursor.svg);"
which is broken due to the unescaped double quotes