Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

fix(nav-bar): null check tabs when updating nav-bar #9071

Merged
merged 1 commit into from
Jan 3, 2017

Conversation

samelliottdlt
Copy link
Contributor

It is possible that _getTabs returns an array of undefined when mapping over linkArray as .controller('mdNavItem') can return undefined if it cannot find the corresponding controller which will cause an error to be shown in the console during the digest cycle.

This change assures that we do not attempt to update the tabs in the case that tabs is an undefined array.

@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

1 similar comment
@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@samelliottdlt
Copy link
Contributor Author

Signed CLA

@googlebot
Copy link

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

@ThomasBurleson
Copy link
Contributor

Please provide 1-2 unit tests for these. Thx @samdlt .

@ThomasBurleson ThomasBurleson added the needs: unit tests This PR needs unit tests to cover the changes being proposed label Jul 19, 2016
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

1 similar comment
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@googlebot
Copy link

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

@samelliottdlt
Copy link
Contributor Author

@ThomasBurleson added unit tests

@topherfangio topherfangio added needs: review This PR is waiting on review from the team and removed needs: group review needs: unit tests This PR needs unit tests to cover the changes being proposed labels Sep 9, 2016
oldTab.setSelected(false);
oldIndex = tabs.indexOf(oldTab);
}
if (tabs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent nesting, we can change this to if (!tabs) return;. We can also move it up to before oldIndex and newIndex are initialized.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, can you return immediately and as soon as possible?

@clshortfuse
Copy link
Contributor

Fixes #9386

Can you add that to the commit message?

@clshortfuse clshortfuse changed the title Null check tabs in md-nav-bar fix(nav-bar): null check tabs when updating nav-bar Sep 9, 2016
.map(function(el) {
return angular.element(el).controller('mdNavItem')
});
return linkArray.indexOf() === -1 ? linkArray : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linkArray.indexOf(undefined) reads a little better to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controllers instead of linkArray plz.

@samelliottdlt
Copy link
Contributor Author

@gmoothart @clshortfuse Thanks for taking a look at this guys. I'll address the comments either tomorrow or Monday.

Copy link
Contributor

@gmoothart gmoothart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, pending some minor comments.

@@ -209,6 +209,10 @@ MdNavBarController.prototype._initTabs = function() {
MdNavBarController.prototype._updateTabs = function(newValue, oldValue) {
var self = this;
var tabs = this._getTabs();

if(!tabs)
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment here explaining why tabs might be null?

@ThomasBurleson
Copy link
Contributor

@samdlt - FYI, we will not merge until the review feedback is addressed and the PR refreshed with updates.

@ThomasBurleson ThomasBurleson added needs: work in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs and removed needs: review This PR is waiting on review from the team labels Sep 15, 2016
@ThomasBurleson ThomasBurleson added this to the 1.1.2 milestone Sep 15, 2016
Copy link
Contributor

@gmoothart gmoothart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -209,6 +209,11 @@ MdNavBarController.prototype._initTabs = function() {
MdNavBarController.prototype._updateTabs = function(newValue, oldValue) {
var self = this;
var tabs = this._getTabs();

// this._getTabs can return an array of undefined if nav-bar has not yet been initialized
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) technically it returns null, not an array of undefined.

@gmoothart
Copy link
Contributor

@samdlt can you resolve the merge conflicts and then we can merge this?

@samelliottdlt
Copy link
Contributor Author

@gmoothart merged and resolved conflict

@ThomasBurleson ThomasBurleson added needs: presubmit and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs needs: work labels Oct 9, 2016
@jelbourn
Copy link
Member

jelbourn commented Dec 2, 2016

@samdlt can you rebase?

@googlebot googlebot added cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ labels Dec 6, 2016
@samelliottdlt
Copy link
Contributor Author

@jelbourn rebased

@kara kara added pr: merge ready This PR is ready for a caretaker to review and removed needs: presubmit labels Jan 3, 2017
@kara kara merged commit b38d928 into angular:master Jan 3, 2017
davidenochk pushed a commit to davidenochk/material that referenced this pull request Feb 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants