Skip to content

Commit

Permalink
[fix] prevent crashing when tag attributes are empty (#2492)
Browse files Browse the repository at this point in the history
Fixes #2491
  • Loading branch information
ignatiusmb committed Sep 25, 2021
1 parent 2b54b65 commit 791e2a4
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
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>

0 comments on commit 791e2a4

Please sign in to comment.