Skip to content

Commit 9af16b9

Browse files
committed
[scramjet] check script type before trying to rerwite
1 parent 84076d9 commit 9af16b9

File tree

1 file changed

+8
-2
lines changed
  • packages/scramjet/packages/core/src/client/dom

1 file changed

+8
-2
lines changed

packages/scramjet/packages/core/src/client/dom/element.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ export default function (client: ScramjetClient, self: typeof window) {
290290
client.Trap("Element.prototype.innerHTML", {
291291
set(ctx, value: string) {
292292
let newval;
293-
if (ctx.this instanceof self.HTMLScriptElement) {
293+
if (
294+
ctx.this instanceof self.HTMLScriptElement &&
295+
/(application|text)\/javascript|module|undefined/.test(ctx.this.type)
296+
) {
294297
newval = rewriteJs(value, "(anonymous script element)", client.meta);
295298
client.natives.call(
296299
"Element.prototype.setAttribute",
@@ -335,7 +338,10 @@ export default function (client: ScramjetClient, self: typeof window) {
335338
client.Trap("Node.prototype.textContent", {
336339
set(ctx, value: string) {
337340
// TODO: box the instanceofs
338-
if (ctx.this instanceof self.HTMLScriptElement) {
341+
if (
342+
ctx.this instanceof self.HTMLScriptElement &&
343+
/(application|text)\/javascript|module|undefined/.test(ctx.this.type)
344+
) {
339345
const newval: string = rewriteJs(
340346
value,
341347
"(anonymous script element)",

0 commit comments

Comments
 (0)