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

Changing firstObject does not cause a rerender. #13240

Closed
Serabe opened this issue Apr 3, 2016 · 7 comments
Closed

Changing firstObject does not cause a rerender. #13240

Serabe opened this issue Apr 3, 2016 · 7 comments

Comments

@Serabe
Copy link
Member

Serabe commented Apr 3, 2016

Given the following template:

{{#each collection as |item|}}
  {{item}}
{{/each}}

Setting collection.firstObject to a different value does not rerender.

Twiddle

@chancancode
Copy link
Member

Is that a supported way to mutate an ember array? o_0 cc @rwjblue

@rwjblue
Copy link
Member

rwjblue commented Apr 3, 2016

I would not expect someArray.set('firstObject', 'foo'); to set the first item today, though I do suppose that if you think about it when you call someArray.get('firstObject') it works so it is somewhat surprising that you can't set it...

@Serabe
Copy link
Member Author

Serabe commented Apr 3, 2016

I would expect that the call either sets it or raises a readOnly assertion (Cannot set read-only property firstObject on object: x).

@rwjblue
Copy link
Member

rwjblue commented Apr 3, 2016

@Serabe - Ya, I agree that silently failing isn't good. I would lean towards making it a readOnly error I think...

Open to suggestions from @krisselden / @mmun though...

@mmun
Copy link
Member

mmun commented Apr 3, 2016

Setting firstObject should raise an error, yes. It might be possible that this introduces errors in people's apps where there weren't any previously, e.g. in {{foo-bar baz=array.firstObject}} because of the two-way binding, but I'd guess it would be pretty rare.

@rwjblue
Copy link
Member

rwjblue commented Apr 3, 2016

Ya, it seems rare and also a likely source for other bugs...

@pixelhandler
Copy link
Contributor

Perhaps some clarity can be added to the API docs for firstObject that it should not be set. The doc does mention that its a helper method to get something. But since its listed as a property one would think that it's ok to get and set. Which is not the case.

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

No branches or pull requests

5 participants