Skip to content

Commit

Permalink
fix: #181
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Nov 22, 2024
1 parent fd1b5cf commit 00df413
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/generators/template/bindings/slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export default function createSlotBinding(
getChildrenNodes(sourceNode).length
? createTemplateProperty(
createNestedBindings(
sourceNode,
// the root attributes should be removed
{ ...sourceNode, attributes: [] },
sourceFile,
sourceCode,
selectorAttribute,
Expand Down
12 changes: 12 additions & 0 deletions test/generators/template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,18 @@ describe('Generators - Template', () => {
expect(output[BINDING_TEMPLATE_KEY]).to.be.not.ok
})

it('Slot with fallback (avoid duplicate attributes)', () => {
const source = '<slot message={ message }><p>hi</p></slot>'

const { template } = parse(source)
const input = slotBinding(template, 'expr0', FAKE_SRC_FILE, source)
const output = generateJavascript(input).code

// no expressions should be generated in the template fallback
// the slot root attributes should be removed
expect(output).to.not.match(/expressions/)
})

it('Slot fallback html', () => {
const source =
'<div><slot><ul><li each={item in items}>{item}</li></ul></slot></div>'
Expand Down

0 comments on commit 00df413

Please sign in to comment.