ui-router: bug fix proposed
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;
}
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 22 (4 by maintainers)
I was experiencing the same issues mentioned here, but they went away after I upgraded from 0.2.15 to 0.2.18.