Repository navigation
fix(chips): safety check before getting length - #6175
StefanFeederle wants to merge 1 commit into
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
|
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.
|
|
@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! |
|
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. |
|
I signed it! |
|
CLAs look good, thanks! |
1 similar comment
|
CLAs look good, thanks! |
|
@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.