Skip to content

Commit

Permalink
test: template provided through @api-decorated prop (#5243)
Browse files Browse the repository at this point in the history
* test: template provided through @api-decorated prop

* chore: add comment
  • Loading branch information
divmain authored Feb 28, 2025
1 parent c04b0b7 commit 340e4a4
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entry": "x/outer"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<fixture-test>
<x-inner>
a
<!---->
slotted content
<!---->
b
<!---->
<div>
named slotted content
</div>
<!---->
c
</x-inner>
</fixture-test>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { LightningElement, api } from 'lwc';

export default class extends LightningElement {
static renderMode = 'light';
@api tmpl;

render() {
return this.tmpl;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template lwc:render-mode="light">
a
<slot>fallback for default</slot>
b
<slot name=foo>fallback for foo</slot>
c
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template lwc:render-mode="light">
<x-inner tmpl={innerTemplateFn}>
slotted content
<div slot="foo">named slotted content</div>
</x-inner>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { LightningElement } from 'lwc';
import innerTemplateFn from './innerTemplateFn.html';
import tmpl from './outer.html';

export default class extends LightningElement {
static renderMode = 'light';
innerTemplateFn = innerTemplateFn;

// This isn't strictly necessary and has no functional value relative to an implicit template. It is present
// only to disambiguate the outer component's template from the one we're passing to the child.
render() {
return tmpl;
}
}

0 comments on commit 340e4a4

Please sign in to comment.