From 84152e0b691b42c58a909edcef1f70ef3c4ec2bc Mon Sep 17 00:00:00 2001 From: ncuillery Date: Fri, 30 May 2014 16:01:10 +0200 Subject: [PATCH] fix($state): change default value of `inherit` option to `true` Since #970, `href()` method takes into account the `inherit` option. This option needs to have a `true` default value in order to not introduce a breaking change. Moreover, the `true` value is more convenient for this "high-level oriented" method. --- src/state.js | 4 ++-- test/stateSpec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/state.js b/src/state.js index 35904c476..9aca42876 100644 --- a/src/state.js +++ b/src/state.js @@ -1091,7 +1091,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { * - **`lossy`** - {boolean=true} - If true, and if there is no url associated with the state provided in the * first parameter, then the constructed href url will be built from the first navigable ancestor (aka * ancestor with a valid url). - * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url. + * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url. * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'), * defines which state to be relative from. * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl". @@ -1101,7 +1101,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { $state.href = function href(stateOrName, params, options) { options = extend({ lossy: true, - inherit: false, + inherit: true, absolute: false, relative: $state.$current }, options || {}); diff --git a/test/stateSpec.js b/test/stateSpec.js index 75e11f268..0c4d6bb6f 100644 --- a/test/stateSpec.js +++ b/test/stateSpec.js @@ -649,7 +649,7 @@ describe('state', function () { it('inherit url parameters from current url', inject(function ($state) { initStateTo($state.get('root'), {param1: 1}); - expect($state.href("root", {}, {})).toEqual("#/root"); + expect($state.href("root", {}, {})).toEqual("#/root?param1=1"); expect($state.href("root", {}, {inherit:false})).toEqual("#/root"); expect($state.href("root", {}, {inherit:true})).toEqual("#/root?param1=1"); }));