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

[breaking] Remove view.$() call in render() of module for component #27

Merged
merged 3 commits into from
Mar 17, 2015

Conversation

bantic
Copy link
Member

@bantic bantic commented Mar 17, 2015

from #26

This PR makes two changes:

  • use a cachedCalls object internally in TestModule to track whether a given callback has been called. Previously, the code only did a check on the result (in this.cache[key]), which means that a callback that returns a falsy value will (incorrectly, it seems) be called multiple times. This seemed likely to result in inconsistent behavior. (This change is necessary for the following change)
  • change this.callbacks.render to not return anything. It simply renders the component. This is a breaking change. Previously, render would return the rendered view's this.$() method, but this is problematic because there are cases where a view's $() method should not be called. Specifically, in Ember 1.11.0.beta-5, calling this.$() on a tagless component (where tagName = '') will result in a failed assertion: "You cannot access this.$() on a component with tagName: \'\' specified.", making it difficult-to-impossible to test such a component in a unit test.

Test users can still call this.$() to get the jquery-wrapped element (in cases where that makes sense — if the component is tagless they will still get the failed assert mentioned above)

cc @rwjblue @mixonic

This prevents a possible error when a callback returns `false` and
therefore it skips the cache.
This is a breaking change.
Previously, calling `this.render()` in a module-for-component would
append the view and then return the view's `this.$()`. This changes
`render` to only render the component and append it, returning
`undefined`.
Test users can still use `this.$()` to get the component's jquery-wrapped element.

This avoids a possible issue in Ember >= 1.11.0-beta.5 where tagless
components (`tagName = ''`) will give a deprecation warning when their
`$()` method is called.
@rwjblue
Copy link
Member

rwjblue commented Mar 17, 2015

👍 - LGTM

@mixonic
Copy link
Sponsor Member

mixonic commented Mar 17, 2015

@bantic can we make append continue to return he jquery object? By trying for and wrapping view.element?

We certain have projects that rely on append returning DOM, and the move to render seems like a good time to change them. But I would be sad if we changed append without backwards compat.

@bantic
Copy link
Member Author

bantic commented Mar 17, 2015

@mixonic coming up...

@bantic
Copy link
Member Author

bantic commented Mar 17, 2015

Updated append test to ensure it:

  • makes a deprecation
  • returns the jquery-wrapped this.$() element

@mixonic
Copy link
Sponsor Member

mixonic commented Mar 17, 2015

+1

@bantic
Copy link
Member Author

bantic commented Mar 17, 2015

@dgeb I think this is good to go, if you are happy with it

dgeb added a commit that referenced this pull request Mar 17, 2015
[breaking] Remove `view.$()` call in `render()` of module for component
@dgeb dgeb merged commit 63b112f into emberjs:master Mar 17, 2015
@dgeb
Copy link
Member

dgeb commented Mar 17, 2015

Good improvements - thanks @bantic!

@dgeb
Copy link
Member

dgeb commented Mar 17, 2015

Just tagged v0.4.0.

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.

None yet

4 participants