Gerrit#updateUiLink: Fix access to undefined property

uiSwitcherLink attribute is instantiated conditionally, when PG UI was
not disabled. The invocation of setHref() method on it:

  uiSwitcherLink.setHref(getUiSwitcherUrl(token));

was done unconditionally. That leads to this error:

  (TypeError) : Cannot read property 'setHref' of undefined

Bug: Issue 5929
Change-Id: I872cdf7d41ab36e03126df54bb12c9071da5543d
This commit is contained in:
David Ostrovsky
2017-04-05 09:07:31 +02:00
committed by David Pursehouse
parent cdeb08b3ea
commit fc555d7854

View File

@@ -598,7 +598,9 @@ public class Gerrit implements EntryPoint {
}
private static void updateUiLink(String token) {
uiSwitcherLink.setHref(getUiSwitcherUrl(token));
if (uiSwitcherLink != null) {
uiSwitcherLink.setHref(getUiSwitcherUrl(token));
}
}
private void onModuleLoad2(HostPageData hpd) {