Uh oh!
There was an error while loading. Please reload this page.
fix(chips): safety check before getting length - #6175
Conversation
If the model is not yet filled (ajax?) this functions fails with: TypeError: Cannot read property 'length' of undefined Ported the fix from: sime/ui-select@1edc16b
googlebot
commented
Dec 8, 2015
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
topherfangio
commented
Feb 4, 2016
@StefanFeederle Can you please add a quick unit test which demonstrates the issue. I'd like to make sure we have a test so we don't introduce a regression later. Thanks! |
StefanFeederle
commented
Feb 13, 2016
Hey @topherfangio, here are two codepens to highlight this issue. I don't know how to write unit tests, sorry. The only difference is that i added the code of this PR in the fixed one. If databinding to a not existing object {{ctrl.form.name}} does not throw errors, md-chips should behave the same and safety-check the object. I know this is not the best coding style and could be circumvented in my code, but i think its also important that angular-material is inherently consistent. This error is really hard to track down for newbies like me. |
StefanFeederle
commented
Feb 13, 2016
I signed it! |
googlebot
commented
Feb 13, 2016
CLAs look good, thanks! |
1 similar comment
googlebot
commented
Feb 13, 2016
CLAs look good, thanks! |
topherfangio
commented
Apr 18, 2016
@ThomasBurleson Would love a unit test to go along with this, but is a NPE check, so it's super-simple. Think we should go ahead and just merge it? |
If the model is not yet filled (ajax?) this functions fails with:
TypeError: Cannot read property 'length' of undefined
If we check the availability of "this.items" before accessing it we bypass this problem.