Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: rollup
run: pnpm build
- name: build
run: pnpm vite build --mode=development
- name: test
Expand Down Expand Up @@ -104,6 +106,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: rollup
run: pnpm build
- name: build
run: pnpm vite build --mode=${{ matrix.BUILD || 'development' }}
- name: test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { service } from '@ember/service';
import { Component } from '@ember/-internals/glimmer';
import { tracked } from '@ember/-internals/metal';
import { set } from '@ember/object';
import GlimmerComponent from '@glimmer/component';
import { backtrackingMessageFor } from '../../utils/debug-stack';
import { runTask } from '../../../../../../internal-test-helpers/lib/run';
import { template } from '@ember/template-compiler';
Expand Down Expand Up @@ -398,6 +399,98 @@ moduleFor(
});
}

async ['@test @model should be stable when transitioning out of the route']() {
let assert = this.assert;

this.router.map(function () {
this.route('a', function () {
this.route('b');
this.route('c');
});
this.route('d', function () {
this.route('e');
});
this.route('f');
});

this.addComponent('foo', {
ComponentClass: class extends GlimmerComponent {
willDestroy() {
assert.step(this.args.model);
}
},
});
this.add(
'route:a',
class extends Route {
model() {
return 'a';
}
}
);
this.add(
'route:a.b',
class extends Route {
model() {
return 'b';
}
}
);
this.addTemplate('a.b', '<Foo @model={{@model}} @controller={{this}} />');
this.add(
'route:a.c',
class extends Route {
model() {
return 'c';
}
}
);
this.add(
'route:d',
class extends Route {
model() {
return 'd';
}
}
);
this.add(
'route:d.e',
class extends Route {
model() {
return 'e';
}
}
);
this.add(
'route:f',
class extends Route {
model() {
return 'f';
}
}
);

await this.visit('/a/b');
await this.visit('/a');

await this.visit('/a/b');
await this.visit('/a/c');

await this.visit('/a/b');
await this.visit('/d');

await this.visit('/a/b');
await this.visit('/d/e');

await this.visit('/a/b');
await this.visit('/f');

this.assert.verifySteps(
['b', 'b', 'b', 'b', 'b'],
'The @model property of the Foo component should be stable in the willDestroy hook'
);
}

['@test it should produce a stable DOM when the model changes']() {
this.router.map(function () {
this.route('color', { path: '/colors/:color' });
Expand Down
8 changes: 8 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ export default defineConfig(({ mode }) => {
viteResolverBug(),
version(),
],
resolve: {
alias: {
'@glimmer/component': resolve(
dirname(fileURLToPath(import.meta.url)),
'./packages/@glimmer/component/dist/index.js'
),
},
},
optimizeDeps: { noDiscovery: true },
publicDir: 'tests/public',
build,
Expand Down
Loading