Add embed format support for script[type="text/jsx"] in html (#17495)
This commit is contained in:
6 files changed
+38
-1
No files matched your search
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user