partytown icon indicating copy to clipboard operation
partytown copied to clipboard

fix: update worker-script innerHTML implementation

Open slawekkolodziej opened this issue 3 years ago • 1 comments

I noticed that setting innerHTML does not work as expected for nested script tags.

Take a look at this code:

div = document.createElement('div');
div.innerHTML = '<script>console.log(42);</script>';
console.log(div.firstChild.innerHTML);

It should log the content of the script. Unfortunately when run inside Partytown it returns empty string.

In addition to the above, I added descriptor for text property, via https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement:

HTMLScriptElement.text A string that joins and returns the contents of all Text nodes inside the element (ignoring other nodes like comments) in tree order. On setting, it acts the same way as the textContent IDL attribute.

slawekkolodziej avatar Aug 02 '22 15:08 slawekkolodziej

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
partytown ✅ Ready (Inspect) Visit Preview Sep 2, 2022 at 3:49PM (UTC)

vercel[bot] avatar Aug 02 '22 15:08 vercel[bot]

@adamdbradley just to clarify, did you close this MR intentionally, or was it closed by mistake automatically, when you merged #235?

slawekkolodziej avatar Aug 29 '22 19:08 slawekkolodziej