Skip to content

bug fix proposed #1901

@dolphinsd

Description

@dolphinsd

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;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions