Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] prevent crashing when tag attributes are empty #2492

Merged
merged 3 commits into from Sep 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-cooks-happen.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Fix script and style tags without attributes crashing svelte-kit package
1 change: 1 addition & 0 deletions packages/kit/src/packaging/index.js
Expand Up @@ -207,6 +207,7 @@ function strip_lang_tags(content) {
'g'
);
content = content.replace(regexp, (tag, attributes) => {
if (!attributes) return tag;
const idx = tag.indexOf(attributes);
return (
tag.substring(0, idx) +
Expand Down
@@ -0,0 +1,4 @@
<script>
/** @type {import('./foo').Foo} */
export let foo;
</script>
@@ -0,0 +1,26 @@
/** @typedef {typeof __propDef.props} PlainProps */
/** @typedef {typeof __propDef.events} PlainEvents */
/** @typedef {typeof __propDef.slots} PlainSlots */
export default class Plain extends SvelteComponentTyped<
{
foo: boolean;
},
{
[evt: string]: CustomEvent<any>;
},
{}
> {}
export type PlainProps = typeof __propDef.props;
export type PlainEvents = typeof __propDef.events;
export type PlainSlots = typeof __propDef.slots;
import { SvelteComponentTyped } from 'svelte';
declare const __propDef: {
props: {
foo: import('./foo').Foo;
};
events: {
[evt: string]: CustomEvent<any>;
};
slots: {};
};
export {};
Expand Up @@ -5,6 +5,7 @@
"type": "module",
"exports": {
"./package.json": "./package.json",
"./Plain.svelte": "./Plain.svelte",
"./Test.svelte": "./Test.svelte",
"./Test2.svelte": "./Test2.svelte",
"./utils": "./utils.js",
Expand Down
@@ -0,0 +1,4 @@
<script>
/** @type {import('./foo').Foo} */
export let foo;
</script>