Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sahinvardar committed Oct 27, 2024
1 parent 658f7f8 commit 2140c2c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 52 deletions.
22 changes: 7 additions & 15 deletions src/print-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,13 @@ const PRINTERS: PrinterCollection = {
MustacheTag: new MustacheTagPrinter(),
Comment: new CommentPrinter(),
Slot: new ElementPrinter(),
// SlotTemplate: new ElementPrinter(),
// Title: new ElementPrinter(),
// Slot: new ElementPrinter(),
// Head: new ElementPrinter(),
// Options: new ElementPrinter(),
// Window: new ElementPrinter(),
// Document: new ElementPrinter(),
// Body: new ElementPrinter(),
// Text: new TextPrinter(),
SlotTemplate: new ElementPrinter(),
Title: new ElementPrinter(),
Head: new ElementPrinter(),
Options: new ElementPrinter(),
Window: new ElementPrinter(),
Document: new ElementPrinter(),
Body: new ElementPrinter(),
Attribute: NoOp,
EventHandler: NoOp,
Identifier: NoOp,
Expand All @@ -462,7 +460,6 @@ const PRINTERS: PrinterCollection = {
Action: NoOp,
Transition: NoOp,
Animation: NoOp,
// Comment: new CommentPrinter(),
IfBlock: new IfBlockPrinter(),
ElseBlock: new ElseBlockPrinter(),
EachBlock: new EachBlockPrinter(),
Expand Down Expand Up @@ -503,8 +500,6 @@ export default function printHtml(params: PrintHtmlParams) {
result += text;
};

let nestingLevel = 0;

const copy = _.cloneDeep(params.rootNode);

walk(copy, {
Expand All @@ -522,8 +517,6 @@ export default function printHtml(params: PrintHtmlParams) {
write,
indent
});

nestingLevel++;
},
leave: function (node: any, parent: any) {
if (node.skip === true) {
Expand All @@ -535,7 +528,6 @@ export default function printHtml(params: PrintHtmlParams) {
write,
indent
});
nestingLevel--;
}
});

Expand Down
74 changes: 37 additions & 37 deletions src/tests/print-html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,40 +155,40 @@ describe('Template', () => {
});
});

// describe('Svelte Component', () => {
// test('<svelte:self>', () => {
// testHtmlPrinter(
// '{#if count > 0}<p>counting down... {count}</p><svelte:self count={count - 1}/>{:else}<p>lift-off!</p>{/if}'
// );
// });

// test('<svelte:window>', () => {
// testHtmlPrinter('<svelte:window on:event={handler}/>');
// });

// test('<svelte:document>', () => {
// testHtmlPrinter('<svelte:document on:event={handler}/>');
// });

// test('<svelte:body>', () => {
// testHtmlPrinter('<svelte:body on:event={handler}/>');
// });

// test('<svelte:head>', () => {
// testHtmlPrinter('<svelte:head><link rel="stylesheet" href="/tutorial/dark-theme.css"/></svelte:head>');
// });

// test('<svelte:element>', () => {
// testHtmlPrinter('<svelte:element this={tag} on:click={handler}>Foo</svelte:element>');
// });

// test('<svelte:component>', () => {
// testHtmlPrinter('<svelte:component this={currentSelection.component} foo={bar}/>');
// });

// test('<svelte:fragment>', () => {
// testHtmlPrinter(
// '<Widget><h1 slot="header">Hello</h1><svelte:fragment slot="footer"><p>All rights reserved.</p><p>Copyright (c) 2019 Svelte Industries</p></svelte:fragment></Widget>'
// );
// });
// });
describe('Svelte Component', () => {
test('<svelte:self>', () => {
testHtmlPrinter(
'{#if count > 0}<p>counting down... {count}</p><svelte:self count={count - 1}/>{:else}<p>lift-off!</p>{/if}'
);
});

test('<svelte:window>', () => {
testHtmlPrinter('<svelte:window on:event={handler}/>');
});

test('<svelte:document>', () => {
testHtmlPrinter('<svelte:document on:event={handler}/>');
});

test('<svelte:body>', () => {
testHtmlPrinter('<svelte:body on:event={handler}/>');
});

test('<svelte:head>', () => {
testHtmlPrinter('<svelte:head><link rel="stylesheet" href="/tutorial/dark-theme.css"/></svelte:head>');
});

test('<svelte:element>', () => {
testHtmlPrinter('<svelte:element this={tag} on:click={handler}>Foo</svelte:element>');
});

test('<svelte:component>', () => {
testHtmlPrinter('<svelte:component this={currentSelection.component} foo={bar}/>');
});

test('<svelte:fragment>', () => {
testHtmlPrinter(
'<Widget><h1 slot="header">Hello</h1><svelte:fragment slot="footer"><p>All rights reserved.</p><p>Copyright (c) 2019 Svelte Industries</p></svelte:fragment></Widget>'
);
});
});

0 comments on commit 2140c2c

Please sign in to comment.