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

didInitAttrs cannot see bound values unless they are explicitly defined on the component class. #12035

Closed
jakesjews opened this issue Aug 10, 2015 · 8 comments

Comments

@jakesjews
Copy link
Contributor

I just noticed this in 1.13.7. If a property isn't explicitly defined on a component's class then its value is never seen in the didInitAttrs method even though it is bound in the template. Defining the property with a value of null does work but this wasn't required in 1.13.6. I'm not 100% sure if this is a bug or if the previous behavior was incorrect and it's been fixed now.

Ember-twiddle at http://ember-twiddle.com/62d39c8e4f57e0eb1fbb

@aortbals
Copy link
Contributor

I can confirm this bug. Immediately after upgrading, I am seeing undefined for an attribute passed to a component in init of the component:

{{foo-component bar='something'}}
init() {
  Ember.assert("The {{foo-component}} attribute 'bar' was not configured", this.get('bar'));
},

The following assert throws in 1.13.7 where it would be correctly bound to 'something' in 1.13.6. I can also confirm that defining the attribute on the component as null fixes the issue. In my experience, it is pretty common to see attributes passed to the component that aren't explicitly defined (regardless of what people feel about the practice of non-explicit attributes).

@ghost
Copy link

ghost commented Aug 11, 2015

I bumped into this too. This was during didReceiveAttrs.
If you declare foo: null on the object things work again.

Here is a jsbin: http://emberjs.jsbin.com/femezafave/1/edit?html,js,console,output

Edit: getAttr does work.

@EricSchank
Copy link
Contributor

I think I have a fix for this, but I'm writing a test to verify -- unless one of you has a breaking test already?

@aortbals
Copy link
Contributor

I do not. That's great to hear though!

@noslouch
Copy link

don't have a breaking test, just a breaking app :-/

@gerry3
Copy link

gerry3 commented Aug 12, 2015

+1

rwjblue added a commit that referenced this issue Aug 13, 2015
[BUGFIX release] use bracket notation to access unknown attr #12035
@rwjblue
Copy link
Member

rwjblue commented Aug 13, 2015

Fixed by #12071.

@rwjblue
Copy link
Member

rwjblue commented Aug 13, 2015

Will be in a 1.13.8 soonish.

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

6 participants