Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

Commit

Permalink
fix(sticky): Use inherited toParams for calculations.
Browse files Browse the repository at this point in the history
closes #288
  • Loading branch information
christopherthielen committed Jan 25, 2016
1 parent 3a2469d commit 83866b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/stickyProvider.js
Expand Up @@ -133,7 +133,8 @@ function $StickyStateProvider($stateProvider, uirextras_coreProvider) {
var keep = 0, state = toPath[keep];

if (transition.options.inherit) {
toParams = inheritParams($stateParams, toParams || {}, $state.$current, transition.toState);
toParams = transition.toParams =
inheritParams($stateParams, toParams || {}, $state.$current, transition.toState);
}

while (state && state === fromPath[keep] && paramsEqualForState(state.ownParams, toParams, transition.fromParams)) {
Expand Down
22 changes: 21 additions & 1 deletion test/stickySpec.js
Expand Up @@ -58,6 +58,10 @@ describe('stickyState', function () {
newStates['typedparam'] = { sticky: true, url: '/typedparam/{boolparam:bool}' };
newStates['typedparam2'] = { sticky: true, url: '/typedparam2/{jsonparam:json}' };

newStates['inherit'] = { url: '/inherit/:id' };
newStates['inherit.one'] = { sticky: true, url: '/one', views: { 'one@inherit': {} } };
newStates['inherit.two'] = { sticky: true, url: '/two', views: { 'two@inherit': {} } };

return newStates;
}

Expand Down Expand Up @@ -574,7 +578,23 @@ describe('stickyState', function () {
inactivated: ['A._2.__1', 'A._2']
});
});
})
});

describe("transitions between sticky states, where params should be inherited", function() {
beforeEach(function() {
ssReset(getNestedStickyStates(), _stateProvider);
});

it("should reactivate the sticky state", function() {
testGo('inherit.one', { entered: ['inherit', 'inherit.one'] }, { params: { id: "1" } } );
expect($state.params.id).toBe("1");
testGo('inherit.two', { entered: 'inherit.two', inactivated: 'inherit.one' }, { inherit: true } );
expect($state.params.id).toBe("1");
testGo('inherit.one', { reactivated: 'inherit.one', inactivated: 'inherit.two' }, { inherit: true } );
expect($state.params.id).toBe("1");
});

});
});

describe('stickyState+ui-sref-active', function () {
Expand Down

0 comments on commit 83866b5

Please sign in to comment.