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

Return passed in value for set and setProperties in integration test #132

Merged
merged 1 commit into from
Dec 11, 2015

Conversation

trentmwillis
Copy link
Member

Address #131.

@@ -169,6 +169,7 @@ export default TestModule.extend({
Ember.run(function() {
Ember.setProperties(context, hash);
});
return hash;
Copy link
Member

Choose a reason for hiding this comment

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

Why doesn't this follow the same pattern as above (returning whatever Ember returns from setProperties)?

Copy link
Member Author

Choose a reason for hiding this comment

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

@rwjblue depending on which version of Ember you're using, Ember.setProperties might return either context or hash. I think it makes more sense for it to return hash so I standardized around that. I can change it if you feel the other behavior is better.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that the Ember behavior changing between 1.x and 2.x is a gotcha, but I'd rather stick with what the framework does here (what if behavior changes again in the future?). Also, the same behavior change exists for this.set (in 1.x this.set returned the context, and in 2.x it returns the value that was set), so we should be consistent between these two.

I think I would prefer to leave the return value undefined (current behavior) for Ember 1.x, and use Ember's return value for 2.x.

This might look something like this:

    context.set = function(key, value) {
      var ret = Ember.run(function() {
        return Ember.set(context, key, value);
      });

      if (hasEmberVersion(2,0)) {
        return ret;
      }
    };

    context.setProperties = function(hash) {
      var ret = Ember.run(function() {
        return Ember.setProperties(context, hash);
      });

      if (hasEmberVersion(2,0)) {
        return ret;
      }
    };

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense to do what the framework does. Not sure I understand the benefit of differentiating on 1.x vs 2.x though.

Copy link
Member

Choose a reason for hiding this comment

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

Mostly that the 1.x behavior was not good, and undefined seems better than letting folks rely on the context being returned only to have that be a breaking change for them when they update to 2.x.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha, seems reasonable. Will update this in a bit.

@trentmwillis
Copy link
Member Author

@rwjblue updated and tests are passing.

@rwjblue
Copy link
Member

rwjblue commented Dec 11, 2015

Awesome, thank you!

rwjblue added a commit that referenced this pull request Dec 11, 2015
Return passed in value for set and setProperties in integration test
@rwjblue rwjblue merged commit 6384b29 into emberjs:master Dec 11, 2015
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.

2 participants