Add embed format support for script[type="text/jsx"] in html (#17495)

This commit is contained in:
汐 authored and GitHub committed 2025-05-27 09:09:14 +08:00
1 parent 441cb1e132
commit 2604b3eeb3
6 files changed
+38 -1

No files matched your search

+2 -1
View File
@@ -91,7 +91,8 @@ function embed(path, options) {
if (
attrMap &&
(attrMap.type === "module" ||
(attrMap.type === "text/babel" &&
((attrMap.type === "text/babel" ||
attrMap.type === "text/jsx") &&
attrMap["data-type"] === "module"))
) {
sourceType = "module";
+1
View File
@@ -343,6 +343,7 @@ function inferParserByTypeAttribute(type) {
case "module":
case "text/javascript":
case "text/babel":
case "text/jsx":
case "application/javascript":
return "babel";
@@ -38,6 +38,10 @@ printWidth: 80
<script type="text/babel">
const someJS = 'this should be formatted'
</script>
<script type="text/jsx">
const someJS = 'this should be formatted'
</script>
<script type="module">
import lib from './lib.js';
@@ -63,6 +67,10 @@ printWidth: 80
<script type="text/babel">
const someJS = "this should be formatted";
</script>
<script type="text/jsx">
const someJS = "this should be formatted";
</script>
<script type="module">
import lib from "./lib.js";
+4
View File
@@ -16,6 +16,10 @@
<script type="text/babel">
const someJS = 'this should be formatted'
</script>
<script type="text/jsx">
const someJS = 'this should be formatted'
</script>
<script type="module">
import lib from './lib.js';
@@ -15,6 +15,15 @@ render(
);
</script>
<script type="text/jsx" data-presets="react" data-type="module">
import { h,
render } from 'https://unpkg.com/preact?module';
render(
<h1>Hello World!</h1>,
document.body
);
</script>
<script type="text/babel">
<!--
alert(1)
@@ -27,6 +36,11 @@ alert(1)
render(<h1>Hello World!</h1>, document.body);
</script>
<script type="text/jsx" data-presets="react" data-type="module">
import { h, render } from "https://unpkg.com/preact?module";
render(<h1>Hello World!</h1>, document.body);
</script>
<script type="text/babel">
<!--
alert(1);
+9
View File
@@ -7,6 +7,15 @@ render(
);
</script>
<script type="text/jsx" data-presets="react" data-type="module">
import { h,
render } from 'https://unpkg.com/preact?module';
render(
<h1>Hello World!</h1>,
document.body
);
</script>
<script type="text/babel">
<!--
alert(1)