ElMassimo/iles

Island broken if prop contains the string `$'`

Closed this issue ยท 2 comments

ouuan commented

Description ๐Ÿ“–

If the prop of an island contains the string $', it will be broken in the production build.

Reproduction ๐Ÿž

https://github.com/ouuan/iles-issue-224-reproduction

The production build output:

    <div id="app"><ile-root id="ile-1"></ile-root><script></script><script type="module" async>import{h as o,c as a}from"/assets/iles.ad977ee4.js";import{_ as r}from"/assets/Foo.dc3d22a4.js";import"/assets/vendor-vue.c0787f6d.js";o(a,r,"ile-1",{foo:"</div>
  </body>
</html>"},{});
</script></div>

The following snippet should be foo:"$'":

foo:"</div>
  </body>
</html>"
ouuan commented

This is a weird issue. I accidentally discovered it because I wrote $'$ in my blog and the search page went broken.

ouuan commented

I found the bug.

content = content.replace(`<!--${island.placeholder}-->`,
// TODO: Remove additional script tag once Firefox is fixed
// https://bugzilla.mozilla.org/show_bug.cgi?id=1737882
`<script></script><script type="module" async>${rebasedCode}</script>`)

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement. I only knew $1, $2 before and this is the first time I hear of $&, $` and $'.