Skip to content

Commit

Permalink
closes #3003
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Apr 26, 2024
1 parent 614dcc7 commit 6205d75
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/get-root-computed-attribute-names.js
Expand Up @@ -9,7 +9,7 @@ import { memoize } from '@riotjs/util'
*/
export const getRootComputedAttributeNames = memoize(
(template) =>
template?.bindingsData?.[0].expressions?.reduce(
template?.bindingsData?.[0]?.expressions?.reduce(
(acc, { name, type }) =>
type === expressionTypes.ATTRIBUTE ? [...acc, name] : acc,
[],
Expand Down
11 changes: 11 additions & 0 deletions test/components/issue-3003-parent.riot
@@ -0,0 +1,11 @@
<issue-3003-parent>
<static-component></static-component>

<script>
import StaticComponent from './static-component.riot'
export default {
components: { StaticComponent }
}
</script>
</issue-3003-parent>
3 changes: 3 additions & 0 deletions test/components/static-component.riot
@@ -0,0 +1,3 @@
<static-component>
<h1>I am static</h1>
</static-component>
12 changes: 12 additions & 0 deletions test/specs/components-rendering.spec.js
Expand Up @@ -2,6 +2,7 @@ import * as riot from '../../src/riot.js'

import Issue2895Parent from '../components/issue-2895-parent.riot'
import Issue2994ClassDuplication from '../components/issue-2994-class-duplication.riot'
import Issue3003Parent from '../components/issue-3003-parent.riot'
import MergeAttributes from '../components/merge-attributes.riot'
import VirtualEach from '../components/virtual-each.riot'

Expand Down Expand Up @@ -66,5 +67,16 @@ describe('components rendering', () => {
})

expect(element.getAttribute('class').trim()).to.be.equal('btn dropdown')

component.unmount()
})

it('nested static components can be rendered without errors', () => {
const element = document.createElement('issue-3003-parent')
const component = riot.component(Issue3003Parent)(element)

expect(() => component.update()).to.not.throw()

component.unmount()
})
})

0 comments on commit 6205d75

Please sign in to comment.