Skip to content

Commit

Permalink
fix(template-compiler): wrong update-path-tree check on template-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
LastLeaf committed Aug 17, 2023
1 parent 0699e00 commit 9fbc52c
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion glass-easel/tests/tmpl/structure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,12 +826,18 @@ describe('node tree structure', () => {
<template name="child">
<span>{{ obj.a }}</span>
</template>
<template name="child2">
<span>{{ a }}</span>
</template>
`,
'': `
<import src="./child" />
<import src="./child" />
<div>
<template is="child" data="{{ obj }}" />
</div>
<div>
<template is="child2" data="{{ ...obj }}" />
</div>
`,
}),
data: {
Expand All @@ -840,7 +846,38 @@ describe('node tree structure', () => {
})
.general()
const elem = glassEasel.Component.createWithContext('root', def, domBackend)
expect(domHtml(elem)).toBe('<div><span>123</span></div><div><span>123</span></div>')
elem.setData({ obj: { a: 456 } })
expect(domHtml(elem)).toBe('<div><span>456</span></div><div><span>456</span></div>')
elem.setData({ 'obj.a': 789 })
expect(domHtml(elem)).toBe('<div><span>789</span></div><div><span>789</span></div>')
})

test('template-name data cascaded passing', () => {
const def = glassEasel
.registerElement({
template: tmpl(`
<template name="child">
<template is="child2" data="{{ a }}" />
</template>
<template name="child2">
<span>{{ a }}</span>
</template>
<div>
<template is="child" data="{{ ...obj }}" />
</div>
`),
data: {
obj: { a: 123 },
},
})
.general()
const elem = glassEasel.Component.createWithContext('root', def, domBackend)
expect(domHtml(elem)).toBe('<div><span>123</span></div>')
elem.setData({ obj: { a: 456 } })
expect(domHtml(elem)).toBe('<div><span>456</span></div>')
elem.setData({ 'obj.a': 789 })
expect(domHtml(elem)).toBe('<div><span>789</span></div>')
})

test('static template-is', () => {
Expand Down

0 comments on commit 9fbc52c

Please sign in to comment.