Skip to content

Commit

Permalink
Add repro from #1629 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Oct 16, 2024
1 parent e8f4a13 commit 9ab9fa4
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { modifierCapabilities, setModifierManager } from '@glimmer/manager';
import { assign } from '@glimmer/util';

import {
BaseEnv,
GlimmerishComponent,
Expand Down Expand Up @@ -40,6 +42,50 @@ class LazyInitializationTest extends RenderTest {

this.assertHTML(`0 0`);
}

@test 'Should be able to lazily initialize with a modifier'() {
const modifier = (callback: () => unknown) => {
setModifierManager(
() => ({
capabilities: modifierCapabilities('3.22'),
createModifier() {},
installModifier() {
callback();
},
updateModifier() {},
destroyModifier() {},
}),
callback
);

return callback;
};

class Thing extends GlimmerishComponent {
@tracked something: string | null = null;

thing = modifier(() => {
if (!this.something) {
this.something = 'something';
}
});
}

this.registerComponent(
'Glimmer',
'HelloWorld',
`
<div {{this.thing}}>
{{this.something}}
</div>
`,
Thing
);

this.render(`<HelloWorld />`);

this.assertHTML(`<div>something</div>`);
}
}

suite(LazyInitializationTest, JitRenderDelegate, {
Expand Down

0 comments on commit 9ab9fa4

Please sign in to comment.