Skip to content

Commit 8ecdc7d

Browse files
authored
(fix) blank content method (#656)
#655
1 parent 5e54e26 commit 8ecdc7d

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

packages/svelte2tsx/src/utils/htmlxparser.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ function blankVerbatimContent(htmlx: string, verbatimElements: Node[]) {
8282
for (const node of verbatimElements) {
8383
const content = node.content;
8484
if (content) {
85-
output = htmlx.substring(0, content.start) +
86-
htmlx.substring(content.start, content.end)
87-
// blank out the content
88-
.replace(/[^\n]/g, ' ')
89-
// excess blank space can make the svelte parser very slow (sec->min). break it up with comments (works in style/script)
90-
.replace(/[^\n][^\n][^\n][^\n]\n/g, '/**/\n') +
91-
htmlx.substring(content.end);
85+
output =
86+
output.substring(0, content.start) +
87+
output
88+
.substring(content.start, content.end)
89+
// blank out the content
90+
.replace(/[^\n]/g, ' ')
91+
// excess blank space can make the svelte parser very slow (sec->min). break it up with comments (works in style/script)
92+
.replace(/[^\n][^\n][^\n][^\n]\n/g, '/**/\n') +
93+
output.substring(content.end);
9294
}
9395
}
9496
return output;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
///<reference types="svelte" />
2+
<></>;function render() {
3+
4+
let foo:string;
5+
;
6+
() => (<>
7+
</>);
8+
return { props: {foo: foo} as {foo: string}, slots: {}, getters: {}, events: {} }}
9+
10+
export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render))) {
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script lang="ts">
2+
export let foo:string;
3+
</script>
4+
<style>
5+
.abc {
6+
font-size: 0;
7+
}
8+
</style>

0 commit comments

Comments
 (0)