-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
sometime locals var in current state is null. the code below throws exception:
function updateView(firstTime) {
var newScope,
name = getUiViewName(scope, attrs, $element, $interpolate),
previousLocals = name && $state.$current && $state.$current.locals[name];
if (!firstTime && previousLocals === latestLocals) return; // nothing to do
newScope = scope.$new();
latestLocals = $state.$current.locals[name];
PROPOSED CODE:
// BUG FIX
var newScope,
name = getUiViewName(scope, attrs, $element, $interpolate);
var previousLocals = null;
if (name && $state.$current && $state.$current.locals)
previousLocals = name && $state.$current && $state.$current.locals[name];
if (!firstTime && previousLocals === latestLocals) return; // nothing to do
newScope = scope.$new();
// BUG FIX
if ($state.$current.locals)
latestLocals = $state.$current.locals[name];
another place where locals are referenced without checking for null is:
var current = $state.$current,
name = getUiViewName(scope, attrs, $element, $interpolate),
locals = current && current.locals[name];
and fix
var current = $state.$current,
name = getUiViewName(scope, attrs, $element, $interpolate);
var locals = null;
if (current && current.locals)
locals = current && current.locals[name];
if (! locals) {
return;
}