Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX Release] fix router test regression for isActive #19789

Closed
Closed
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
666ae33
Disable non-enabled feature
kategengler May 3, 2021
916e104
Add v3.28.0-beta.1 to CHANGELOG
kategengler May 3, 2021
68fccf9
Release v3.28.0-beta.1
kategengler May 3, 2021
173b804
[BUGFIX release] Ensure ember-testing is loaded lazily
May 11, 2021
713a4c2
[BUGFIX release] 3.27 deprecation metadata
chancancode May 11, 2021
d79f94f
[CLEANUP] Deprecations URL consistency
chancancode May 12, 2021
b3b4e53
Release notes for v3.27.1
chancancode May 13, 2021
87b43a1
[BUGFIX] Makes the (hash) helper lazy
Apr 27, 2021
e50dc6e
[BUGFIX release] Make {{hash}} object properties settables
May 19, 2021
6eb573c
[DOC release] fix passing params to named blocks examples
chrisgame May 5, 2021
3b1d38c
fix computed deprecation import path
knownasilya May 6, 2021
01608b7
[BUGFIX] pass module prefix to initializer test blueprints
anehx May 12, 2021
65a75d0
Use explicit this in helper-test blueprints
bertdeblock May 12, 2021
ec0c86e
[BUGFIX release] Improve class based tranform deprecation message
chancancode May 25, 2021
c70dd51
[BUGFIX release] Refine Ember Global deprecation message
chancancode May 25, 2021
edb4e1d
[BUGFIX release] Improve computed.* and run.* deprecation message
chancancode May 26, 2021
d9a66ae
Downlevel for IE11
chancancode May 26, 2021
c54ed9e
fix: lookup/register and singleton flag behavior
runspired Apr 6, 2021
02b4e2e
fix lint
runspired Apr 6, 2021
df6636a
Add v3.27.2 to CHANGELOG.md.
rwjblue May 27, 2021
c203d79
Add v3.28.0-beta.2 to CHANGELOG.md.
rwjblue May 27, 2021
5f368b0
3.28.0-beta.2
rwjblue May 27, 2021
a4099ea
[BUGFIX lts] Ensures that computed can depend on dynamic hash keys
May 27, 2021
a10b4bc
Extend transition deprecation
btecu May 28, 2021
055b923
Add v3.28.0-beta.3 to CHANGELOG
kategengler Jun 1, 2021
20b4eff
Release v3.28.0-beta.3
kategengler Jun 1, 2021
a920b45
[BUGFIX release] Fix Embroider compatibility with ember-source@3.27.2+
rwjblue Jun 3, 2021
edbfc03
Add v3.27.3 to CHANGELOG.md.
rwjblue Jun 3, 2021
e31720c
Add v3.28.0-beta.4 to CHANGELOG
kategengler Jun 7, 2021
2f54b0b
Release v3.28.0-beta.4
kategengler Jun 7, 2021
5571a8b
[DOC release] Fix "Dormant" addon warning typo
ctjhoa Jun 9, 2021
2392417
Add CHANGELOG for v3.27.4
chancancode Jun 9, 2021
1736bfe
[BIGFIX release] Fix `<LinkTo>` with nested children
chancancode Jun 10, 2021
428e7a0
Add CHANGELOG for 3.27.5
chancancode Jun 10, 2021
7de1e20
Add v3.28.0-beta.5 to CHANGELOG
kategengler Jun 14, 2021
e261517
Release v3.28.0-beta.5
kategengler Jun 14, 2021
2971607
[BUGFIX lts] Ensure hash objects correctly entangle as dependencies v2
Jun 1, 2021
a01e11d
Add 3.28.0-beta.6 to CHANGELOG
kategengler Jun 21, 2021
cd55255
Release 3.28.0-beta.6
kategengler Jun 21, 2021
0825f8a
[BUGFIX release] Restore previous hash behavior
Jul 26, 2021
21ecd42
[BUGFIX LTS] fix memory leak in RouterService
Jul 30, 2021
8a4e4af
[BUGFIX release] Deprecate htmlSafe via prototype
mixonic Aug 1, 2021
cf4ccb6
Add HAS_NATIVE_PROXY guard to test for deprecation
kategengler Aug 2, 2021
5365a3c
Merge pull request #19694 from emberjs/kg-add-native-proxy-guard
kategengler Aug 2, 2021
f65283d
Add 3.28.0-beta.7 to CHANGELOG
kategengler Aug 2, 2021
a4bfee9
Release 3.28.0-beta.7
kategengler Aug 2, 2021
8cf4f4a
ensure `deserializeQueryParam` is called for lazy routes
brendenpalmer Aug 5, 2021
5029368
Add v3.28.0 to CHANGELOG
kategengler Aug 9, 2021
f243a4f
Release v3.28.0
kategengler Aug 10, 2021
4e097e6
[BUGFIX release] fix router test regression in urlFor and recognize
chriskrycho Aug 26, 2021
c37df4d
Add v3.28.1 to CHANGELOG.md.
rwjblue Aug 30, 2021
5f4ccf9
Update glimmer-vm to allow locals in loose mode
rwjblue Oct 21, 2021
4c0e61b
Add v3.28.2 to CHANGELOG.md.
rwjblue Oct 21, 2021
5fc912b
3.28.2
rwjblue Oct 21, 2021
eb40ee3
Update glimmer-vm to 0.80.2 (fix some inline precompile issues)
rwjblue Oct 22, 2021
845e827
Add v3.28.3 to CHANGELOG.md.
rwjblue Oct 22, 2021
6932490
3.28.3
rwjblue Oct 22, 2021
1402cb4
Don't pass falsy `locals` to glimmer precompile
ef4 Oct 22, 2021
f41c849
Update glimmer-vm to 0.80.3
rwjblue Oct 22, 2021
d5e3540
Add v3.28.4 to CHANGELOG.md.
rwjblue Oct 22, 2021
62976fe
3.28.4
rwjblue Oct 22, 2021
739b62a
[BUGFIX LTS] fix router test regression for all router service
NullVoxPopuli Oct 14, 2021
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
Prev Previous commit
Next Next commit
fix: lookup/register and singleton flag behavior
(cherry picked from commit 1d49ea9)
runspired authored and rwjblue committed May 27, 2021

Unverified

The email in this signature doesn’t match the committer email.
commit c54ed9eb02ee6b853c6e1f4ac5203d5a5808b039
7 changes: 4 additions & 3 deletions packages/@ember/-internals/container/lib/container.ts
Original file line number Diff line number Diff line change
@@ -272,7 +272,7 @@ function isInstantiatable(container: Container, fullName: string) {
function lookup(container: Container, fullName: string, options: LookupOptions = {}) {
let normalizedName = fullName;

if (options.singleton !== false) {
if (options.singleton === true || (options.singleton === undefined && isSingleton(container, fullName))) {
let cached = container.cache[normalizedName];
if (cached !== undefined) {
return cached;
@@ -335,7 +335,7 @@ function isSingletonInstance(
return (
singleton !== false &&
instantiate !== false &&
isSingleton(container, fullName) &&
(singleton === true || isSingleton(container, fullName)) &&
isInstantiatable(container, fullName)
);
}
@@ -359,7 +359,7 @@ function isFactoryInstance(
) {
return (
instantiate !== false &&
(singleton !== false || isSingleton(container, fullName)) &&
(singleton === false || !isSingleton(container, fullName)) &&
isInstantiatable(container, fullName)
);
}
@@ -379,6 +379,7 @@ function instantiateFactory(
// SomeClass { singleton: true, instantiate: true } | { singleton: true } | { instantiate: true } | {}
// By default majority of objects fall into this case
if (isSingletonInstance(container, fullName, options)) {

let instance = (container.cache[normalizedName] = factoryManager.create() as CacheMember);

// if this lookup happened _during_ destruction (emits a deprecation, but
244 changes: 187 additions & 57 deletions packages/@ember/-internals/container/tests/container_test.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,193 @@ import { DEBUG } from '@glimmer/env';
import { Registry } from '..';
import { factory, moduleFor, AbstractTestCase, runTask } from 'internal-test-helpers';

moduleFor('Container.lookup', class extends AbstractTestCase {

['@test lookup returns a fresh instance if singleton: false is passed as an option'](
assert
) {
let registry = new Registry();
let container = registry.container();
let PostController = factory();

registry.register('controller:post', PostController);

let postController1 = container.lookup('controller:post');
let postController2 = container.lookup('controller:post', {
singleton: false,
});
let postController3 = container.lookup('controller:post', {
singleton: false,
});
let postController4 = container.lookup('controller:post');

assert.equal(
postController1.toString(),
postController4.toString(),
'Singleton factories looked up normally return the same value'
);
assert.notEqual(
postController1.toString(),
postController2.toString(),
'Singleton factories are not equal to factories looked up with singleton: false'
);
assert.notEqual(
postController2.toString(),
postController3.toString(),
'Two factories looked up with singleton: false are not equal'
);
assert.notEqual(
postController3.toString(),
postController4.toString(),
'A singleton factory looked up after a factory called with singleton: false is not equal'
);

assert.ok(
postController1 instanceof PostController,
'All instances are instances of the registered factory'
);
assert.ok(
postController2 instanceof PostController,
'All instances are instances of the registered factory'
);
assert.ok(
postController3 instanceof PostController,
'All instances are instances of the registered factory'
);
assert.ok(
postController4 instanceof PostController,
'All instances are instances of the registered factory'
);
}

['@test lookup returns a fresh instance if singleton: false is passed as an option to lookup'](
assert
) {
class TestFactory {
constructor(opts) {
Object.assign(this, opts);
}
static create(opts) {
return new this(opts);
}
}

let registry = new Registry();
let container = registry.container();
registry.register('thing:test/obj', TestFactory);

let instance1 = container.lookup('thing:test/obj');
let instance2 = container.lookup('thing:test/obj', {
singleton: false,
});
let instance3 = container.lookup('thing:test/obj', {
singleton: false,
});
let instance4 = container.lookup('thing:test/obj');

assert.ok(instance1 === instance4, 'factories looked up up without singleton: false are the same instance');
assert.ok(instance1 !== instance2, 'factories looked up with singleton: false are a different instance');
assert.ok(instance2 !== instance3, 'factories looked up with singleton: false are a different instance');
assert.ok(instance3 !== instance4, 'factories looked up after a call to singleton: false is a different instance');
assert.ok(
instance1 instanceof TestFactory,
'All instances are instances of the registered factory'
);
assert.ok(
instance2 instanceof TestFactory,
'All instances are instances of the registered factory'
);
assert.ok(
instance3 instanceof TestFactory,
'All instances are instances of the registered factory'
);
assert.ok(
instance4 instanceof TestFactory,
'All instances are instances of the registered factory'
);
}

['@test lookup returns a fresh instance if singleton: false is passed as an option to register'](
assert
) {
class TestFactory {
constructor(opts) {
Object.assign(this, opts);
}
static create(opts) {
return new this(opts);
}
}

let registry = new Registry();
let container = registry.container();
registry.register('thing:test/obj', TestFactory, { singleton: false });

let instance1 = container.lookup('thing:test/obj');
let instance2 = container.lookup('thing:test/obj');
let instance3 = container.lookup('thing:test/obj');

assert.ok(instance1 !== instance2, 'each lookup is a different instance');
assert.ok(instance2 !== instance3, 'each lookup is a different instance');
assert.ok(instance1 !== instance3, 'each lookup is a different instance');
assert.ok(
instance1 instanceof TestFactory,
'All instances are instances of the registered factory'
);
assert.ok(
instance2 instanceof TestFactory,
'All instances are instances of the registered factory'
);
assert.ok(
instance3 instanceof TestFactory,
'All instances are instances of the registered factory'
);
}

['@test lookup returns a singleton instance if singleton: true is passed as an option even if registered as singleton: false'](
assert
) {
class TestFactory {
constructor(opts) {
Object.assign(this, opts);
}
static create(opts) {
return new this(opts);
}
}

let registry = new Registry();
let container = registry.container();
registry.register('thing:test/obj', TestFactory, { singleton: false });

let instance1 = container.lookup('thing:test/obj');
let instance2 = container.lookup('thing:test/obj', { singleton: true });
let instance3 = container.lookup('thing:test/obj', { singleton: true });
let instance4 = container.lookup('thing:test/obj');

assert.ok(instance1 !== instance2, 'each lookup is a different instance');
assert.ok(instance2 === instance3, 'each singleton: true lookup is the same instance');
assert.ok(instance3 !== instance4, 'each lookup is a different instance');
assert.ok(instance1 !== instance4, 'each lookup is a different instance');
assert.ok(
instance1 instanceof TestFactory,
'All instances are instances of the registered factory'
);
assert.ok(
instance2 instanceof TestFactory,
'All instances are instances of the registered factory'
);
assert.ok(
instance3 instanceof TestFactory,
'All instances are instances of the registered factory'
);
assert.ok(
instance4 instanceof TestFactory,
'All instances are instances of the registered factory'
);
}
});

moduleFor(
'Container',
class extends AbstractTestCase {
@@ -45,63 +232,6 @@ moduleFor(
);
}

['@test A registered factory returns a fresh instance if singleton: false is passed as an option'](
assert
) {
let registry = new Registry();
let container = registry.container();
let PostController = factory();

registry.register('controller:post', PostController);

let postController1 = container.lookup('controller:post');
let postController2 = container.lookup('controller:post', {
singleton: false,
});
let postController3 = container.lookup('controller:post', {
singleton: false,
});
let postController4 = container.lookup('controller:post');

assert.equal(
postController1.toString(),
postController4.toString(),
'Singleton factories looked up normally return the same value'
);
assert.notEqual(
postController1.toString(),
postController2.toString(),
'Singleton factories are not equal to factories looked up with singleton: false'
);
assert.notEqual(
postController2.toString(),
postController3.toString(),
'Two factories looked up with singleton: false are not equal'
);
assert.notEqual(
postController3.toString(),
postController4.toString(),
'A singleton factory looked up after a factory called with singleton: false is not equal'
);

assert.ok(
postController1 instanceof PostController,
'All instances are instances of the registered factory'
);
assert.ok(
postController2 instanceof PostController,
'All instances are instances of the registered factory'
);
assert.ok(
postController3 instanceof PostController,
'All instances are instances of the registered factory'
);
assert.ok(
postController4 instanceof PostController,
'All instances are instances of the registered factory'
);
}

["@test A factory type with a registered injection's instances receive that injection"](
assert
) {