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 beta] Make container always return the same value even if the registered value is falsy #12797

Merged
merged 4 commits into from
Jan 14, 2016

Conversation

hibariya
Copy link
Contributor

This fixes #12796.

@rwjblue
Copy link
Member

rwjblue commented Jan 10, 2016

Looks good to me.

@dgeb / @stefanpenner - r?

@@ -849,12 +849,14 @@ function resolve(registry, normalizedName, options) {
resolved = registry.resolver.resolve(normalizedName);
}

resolved = resolved || registry.registrations[normalizedName];
if (resolved === undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this expression the opposite of what we want?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't understand what is the problem. I think this change is necessary for the following case:

QUnit.test('The value returned from resolver is the same value as the original value even if the value is falsy', function() {
  let resolver = {
    resolve(fullName) {
      if (fullName === 'falsy:value') {
        return null;
      }
    }
  };
  let registry = new Registry({ resolver });

  deepEqual(registry.resolve('falsy:value'), null);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the above test.

@dgeb
Copy link
Member

dgeb commented Jan 14, 2016

Looks good to me as well. Thanks @hibariya 👍

@stefanpenner
Copy link
Member

👍

rwjblue added a commit that referenced this pull request Jan 14, 2016
[BUGFIX beta] Make container always return the same value even if the registered value is falsy
@rwjblue rwjblue merged commit ce42e00 into emberjs:master Jan 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Container doesn't return the same value if the registered value is falsy
4 participants