Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/svelte2tsx/src/htmlxtojsx/nodes/debug.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import MagicString from 'magic-string';
import { Node } from 'estree-walker';
import MagicString from 'magic-string';

/**
* {@debug ...} ---> {...}
* {@debug a} ---> {a}
* {@debug a, b} ---> {a}{b}
* tsx won't accept commas, must split
*/
export function handleDebug(htmlx: string, str: MagicString, debugBlock: Node): void {
const tokenStart = htmlx.indexOf('@debug', debugBlock.start);
str.remove(tokenStart, tokenStart + '@debug'.length);
export function handleDebug(_htmlx: string, str: MagicString, debugBlock: Node): void {
let cursor = debugBlock.start;
for (const identifier of debugBlock.identifiers as Node[]) {
str.remove(cursor, identifier.start);
str.prependLeft(identifier.start, '{');
str.prependLeft(identifier.end, '}');
cursor = identifier.end;
}
str.remove(cursor, debugBlock.end);
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<>{ myfile, someOtherFile }</>
<>{myfile}
{myfile}{someOtherFile}
{myfile}{someOtherFile}{someThirdFile}</>
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{@debug myfile, someOtherFile }
{@debug myfile}
{@debug myfile , someOtherFile }
{@debug myfile, someOtherFile, someThirdFile }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
///<reference types="svelte" />
<></>;function render() {
<>{myfile}
{__sveltets_store_get(myfile)}{someOtherFile}
{myfile}{__sveltets_store_get(someOtherFile)}{someThirdFile}</>
return { props: {}, slots: {}, getters: {}, events: {} }}

export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render))) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{@debug myfile}
{@debug $myfile , someOtherFile }
{@debug myfile, $someOtherFile, someThirdFile }