feat: don't limit server script to head
This commit is contained in:
parent
69499d61ab
commit
b87f7ee5dc
3 changed files with 9 additions and 5 deletions
|
@ -47,12 +47,10 @@ function doSetUp(html: string) {
|
||||||
const { attributes } = node;
|
const { attributes } = node;
|
||||||
const attributeKeys = Object.keys(attributes ?? {});
|
const attributeKeys = Object.keys(attributes ?? {});
|
||||||
const isServerScript = attributeKeys.some((key) => key.includes("server:"));
|
const isServerScript = attributeKeys.some((key) => key.includes("server:"));
|
||||||
const isInHead = node.parent?.name === "head";
|
|
||||||
if (
|
if (
|
||||||
node.type === ELEMENT_NODE &&
|
node.type === ELEMENT_NODE &&
|
||||||
node.name === "script" &&
|
node.name === "script" &&
|
||||||
isServerScript &&
|
isServerScript
|
||||||
isInHead
|
|
||||||
) {
|
) {
|
||||||
const scripts = node.children.map((child) => child.value);
|
const scripts = node.children.map((child) => child.value);
|
||||||
serverScripts.push(scripts.join(" "));
|
serverScripts.push(scripts.join(" "));
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
wow we can't find that
|
<script server:setup>
|
||||||
|
let greeting = "hello";
|
||||||
|
</script>
|
||||||
|
{{greeting}}!! wow we can't find that
|
||||||
|
|
|
@ -4,9 +4,12 @@
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>top about</title>
|
<title>top about</title>
|
||||||
|
<script server:setup>
|
||||||
|
let greeting = "hello";
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<a href="/">Home</a>
|
<a href="/">Home</a>
|
||||||
<h1>Top Level About</h1>
|
<h1>{{greeting}}!!! Top Level About</h1>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue