Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: angular-ui/ui-router
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.13
Choose a base ref
...
head repository: angular-ui/ui-router
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.0.14
Choose a head ref

Commits on Jan 10, 2018

  1. Copy the full SHA
    f215e9f View commit details
  2. Copy the full SHA
    8f1ae6a View commit details
  3. Copy the full SHA
    70fb08d View commit details
  4. Copy the full SHA
    d78dffa View commit details
  5. Copy the full SHA
    19b042d View commit details

Commits on Jan 11, 2018

  1. Merge pull request #3599 from angular-ui/greenkeeper/rollup-0.53.4

    Update rollup to the latest version 🚀
    christopherthielen authored Jan 11, 2018
    Copy the full SHA
    1cb656f View commit details
  2. Copy the full SHA
    3a7d8d9 View commit details
  3. Copy the full SHA
    e751ea3 View commit details
  4. Merge pull request #3600 from angular-ui/greenkeeper/rollup-plugin-no…

    …de-resolve-3.0.1
    
    Update rollup-plugin-node-resolve to the latest version 🚀
    christopherthielen authored Jan 11, 2018
    Copy the full SHA
    d913e9d View commit details
  5. Merge pull request #3598 from angular-ui/greenkeeper/fork-ts-checker-…

    …webpack-plugin-0.3.0
    
    Update fork-ts-checker-webpack-plugin to the latest version 🚀
    christopherthielen authored Jan 11, 2018
    Copy the full SHA
    2396232 View commit details

Commits on Jan 21, 2018

  1. Copy the full SHA
    4c8a6d6 View commit details

Commits on Jan 25, 2018

  1. Copy the full SHA
    b92a07c View commit details

Commits on Jan 26, 2018

  1. Copy the full SHA
    01430ee View commit details
  2. Copy the full SHA
    c582c9c View commit details

Commits on Jan 28, 2018

  1. Copy the full SHA
    c655119 View commit details

Commits on Jan 30, 2018

  1. Copy the full SHA
    1a35796 View commit details
  2. Copy the full SHA
    c6c24e4 View commit details
  3. Copy the full SHA
    f87e857 View commit details
  4. Copy the full SHA
    f132fef View commit details
  5. Copy the full SHA
    d56addc View commit details
  6. Merge pull request #3619 from fpipita/master

    fix(uiSrefActive): don't match fuzzy on lazy loaded future states
    christopherthielen authored Jan 30, 2018
    Copy the full SHA
    0a807ae View commit details
  7. feat(uiSrefActive): Support arrays of globs for ng-class style

    i.e., <div ui-sref-active="{ active: ['randomState.**', admin.roles'] }"></div>
    
    Closes #2524
    christopherthielen committed Jan 30, 2018
    Copy the full SHA
    b215343 View commit details
  8. Copy the full SHA
    915ac65 View commit details

Commits on Jan 31, 2018

  1. Copy the full SHA
    480b232 View commit details
  2. 1.0.14

    christopherthielen committed Jan 31, 2018
    Copy the full SHA
    032c67d View commit details
Showing with 911 additions and 436 deletions.
  1. +10 −14 .travis.yml
  2. +28 −0 CHANGELOG.md
  3. +1 −1 bower.json
  4. +26 −29 package.json
  5. +52 −12 src/directives/stateDirectives.ts
  6. +0 −5 test/noimplicitany.ts
  7. +95 −0 test/stateDirectivesSpec.js
  8. +1 −0 test/typescript2.3/package.json
  9. +1 −0 test/typescript2.4/package.json
  10. +1 −0 test/typescript2.5/package.json
  11. +1 −0 test/typescript2.6/package.json
  12. +695 −375 yarn.lock
24 changes: 10 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
language: node_js
node_js: '8.9.1'

node_js: 8.9.1
before_install: yarn global add greenkeeper-lockfile@1 yalc
install: yarn --check-files

before_script: greenkeeper-lockfile-update && greenkeeper-lockfile-upload
script:
# If CORE_BRANCH is set, fetch and build the @uirouter/core branch from github, then install it
- if [ "x${CORE_BRANCH}x" != "xx" ] ; then ./node_modules/.bin/publish_yalc_package .downstream_cache/core https://github.com/ui-router/core.git && yalc add @uirouter/core ; fi
# If DOWNSTREAM or DOWNSTREAM_PKGS is set, run downstream packages' tests instead
- if [ "x${DOWNSTREAM_PKGS}${DOWNSTREAM}x" != "xx" ] ; then npm run test:downstream ; else tsc && npm test ; fi

- if [ "x${CORE_BRANCH}x" != "xx" ] ; then ./node_modules/.bin/publish_yalc_package
.downstream_cache/core https://github.com/ui-router/core.git && yalc add @uirouter/core
; fi
- if [ "x${DOWNSTREAM_PKGS}${DOWNSTREAM}x" != "xx" ] ; then npm run test:downstream
; else tsc && npm test ; fi
env:
global:
secure: TanWbkSRljYf0ENPiF3LDM+6RDYyUZoVIIQjUk9UDZ1MBvzEiqISB/zKSXSoYY1JNZpNcXgje2Sl08yGhAugRVodH+FJa/khSkXwRsZAlJuG8qPFAevW4gffvJvPAE7O0uy4jLyyu+Fi9dptdi1zDGsOps/Q+WURH9jWPGmQpj8=
@@ -19,22 +17,20 @@ env:
- CORE_BRANCH=master
- CORE_BRANCH=master UPSTREAM_PKGS=@uirouter/core DOWNSTREAM=true
- DOWNSTREAM=true

matrix:
fast_finish: true
allow_failures:
- env: CORE_BRANCH=
- env: DOWNSTREAM=true
- env: CORE_BRANCH=master UPSTREAM_PKGS=@uirouter/core DOWNSTREAM=true

notifications:
slack:
secure: LqlW9u5Lyh7eHffLqfrIEyIdpqJmPg29NQHqjM6ij2BUFOs9se+NgpRagfICukCEMimOdzEiIE6S4DXNhCcy6hoA24cpswb84vHRuZ4pFz8USq13rX72AgygR1tPKB9sbXLp+XIjRaLPO5z8asECCr7jxSCpMvHRylPAGL4DduI=

on_success: change
rooms:
secure: alXA+pERLtF4DNctl+WaISO3uzUA/JzVCzSrDlNsV9Jvx1HdAqRNbrrnNYzCZBIU6OOv5YBGFbq79v5NPKzMPzoR8dp3PahlxRgucxALweoTCXY5DuDHVSI9ULLl2PND7QOfKyUALuAz5nmT7omPVxRKCpBkVsqewLfMeW1MRgE=
sudo: false

cache:
yarn: true
directories:
- .downstream_cache
- ".downstream_cache"
- node_modules
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## 1.0.14 (2018-01-31)
[Compare `@uirouter/angularjs` versions 1.0.13 and 1.0.14](https://github.com/angular-ui/ui-router/compare/1.0.13...1.0.14)

### Bug Fixes

* **uiSrefActive:** don't match fuzzy on lazy loaded future states ([01430ee](https://github.com/angular-ui/ui-router/commit/01430ee))


### Features

* **uiSrefActive:** Support arrays of globs for ng-class style ([b215343](https://github.com/angular-ui/ui-router/commit/b215343))


### Updated `@uirouter/core` from 5.0.14 to 5.0.16
[Compare `@uirouter/core` versions 5.0.14 and 5.0.16](https://github.com/ui-router/core/compare/5.0.14...5.0.16)

### Bug Fixes

* **common:** Fix signature of for objects (make target optional) ([61d0afc](https://github.com/ui-router/core/commit/61d0afc))
* **core:** Fix memory leak of resolve data from ALL transitions ever ([7f2aed1](https://github.com/ui-router/core/commit/7f2aed1))
* **pathNode:** add backwards compat for PathNode.clone(). Add retainedWithToParams to treeChanges interface. ([4833a32](https://github.com/ui-router/core/commit/4833a32))


### Features

* **common:** Add map-in-place support to map() ([12bc7d8](https://github.com/ui-router/core/commit/12bc7d8))
* **common:** Add onEvict() callback registry for queues with max length ([c19d007](https://github.com/ui-router/core/commit/c19d007))

## 1.0.13 (2018-01-10)
[Compare `@uirouter/angularjs` versions 1.0.12 and 1.0.13](https://github.com/angular-ui/ui-router/compare/1.0.12...1.0.13)

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -17,5 +17,5 @@
"test",
"src"
],
"version": "1.0.12"
"version": "1.0.13"
}
55 changes: 26 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@uirouter/angularjs",
"description": "State-based routing for AngularJS 1.x",
"version": "1.0.13",
"version": "1.0.14",
"scripts": {
"clean": "shx rm -rf lib lib-esm _doc build release *.log",
"compile": "tsc && tsc -m es6 --outDir lib-esm && npm run fixdts",
@@ -15,8 +15,7 @@
"bundle_router": "rollup -c --environment ROUTER && rollup -c --environment ROUTER,MINIFY",
"bundle_events": "rollup -c --environment EVENTS && rollup -c --environment EVENTS,MINIFY",
"bundle_resolve": "rollup -c --environment RESOLVE && rollup -c --environment RESOLVE,MINIFY",
"noimplicitany": "tsc --noEmit --noImplicitAny --moduleResolution node --target es6 test/noimplicitany.ts",
"test": "tsc && npm run noimplicitany && npm run test:ng16 && npm run test:ng15 && npm run test:ng14 && npm run test:ng13 && npm run test:ng12",
"test": "tsc && npm run test:ng16 && npm run test:ng15 && npm run test:ng14 && npm run test:ng13 && npm run test:ng12",
"test:ng12": "karma start --ngversion 1.2",
"test:ng13": "karma start --ngversion 1.3",
"test:ng14": "karma start --ngversion 1.4",
@@ -26,7 +25,7 @@
"watch": "karma start --singleRun=false --autoWatch=true --autoWatchInterval=1",
"debug": "karma start --singleRun=false --autoWatch=true --autoWatchInterval=1 --browsers=Chrome",
"docs": "./scripts/docs.js",
"release": "npm run noimplicitany && release --deps @uirouter/core && node ./scripts/bower_release.js",
"release": "release --deps @uirouter/core && node ./scripts/bower_release.js",
"prepublishOnly": "npm run build",
"publishdocs": "node scripts/publishdocs.js",
"artifacts": "artifact_tagging"
@@ -72,47 +71,45 @@
"jsnext:main": "lib-esm/index.js",
"typings": "lib/index.d.ts",
"dependencies": {
"@uirouter/core": "5.0.14"
"@uirouter/core": "5.0.16"
},
"peerDependencies": {
"angular": ">=1.2.0"
},
"devDependencies": {
"@types/angular": "^1.5.14",
"@types/angular-animate": "^1.5.5",
"@types/angular": "^1.6.42",
"@types/angular-animate": "1.5.9",
"@types/angular-mocks": "1.5.11",
"@types/jasmine": "2.8.3",
"@types/jquery": "^3.2.17",
"@uirouter/publish-scripts": "2.2.4",
"conventional-changelog": "1.1.7",
"conventional-changelog-cli": "1.3.5",
"dts-downlevel": "^0.3.0",
"fork-ts-checker-webpack-plugin": "^0.2.8",
"jasmine-core": "2.8.0",
"@types/jasmine": "2.8.6",
"@types/jquery": "3.3.0",
"@uirouter/publish-scripts": "2.2.10",
"dts-downlevel": "0.3.0",
"fork-ts-checker-webpack-plugin": "0.3.0",
"jasmine-core": "2.9.1",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-jasmine": "1.1.1",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-phantomjs-launcher": "1.0.4",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.9",
"lodash": "^4.5.1",
"lodash": "4.17.4",
"replace-in-file": "3.1.0",
"rollup": "0.53.3",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-sourcemaps": "^0.4.1",
"rollup-plugin-uglify": "2.0.1",
"shelljs": "^0.7.0",
"rollup": "0.55.1",
"rollup-plugin-node-resolve": "3.0.2",
"rollup-plugin-sourcemaps": "0.4.2",
"rollup-plugin-uglify": "3.0.0",
"shelljs": "0.8.1",
"shx": "0.2.2",
"ts-loader": "3.2.0",
"tslint": "5.9.0",
"tslint-eslint-rules": "^4.1.1",
"typedoc": "^0.9.0",
"ts-loader": "3.3.1",
"tslint": "5.9.1",
"tslint-eslint-rules": "4.1.1",
"typedoc": "0.9.0",
"typedoc-plugin-external-module-name": "1.0.10",
"typedoc-plugin-internal-external": "1.0.10",
"typedoc-plugin-single-line-tags": "1.0.0",
"typedoc-plugin-ui-router": "^1.0.0",
"typedoc-plugin-ui-router": "1.0.6",
"typescript": "2.6.2",
"ui-router-typedoc-themes": "^1.0.1",
"ui-router-typedoc-themes": "1.0.2",
"webpack": "3.10.0"
}
}
64 changes: 52 additions & 12 deletions src/directives/stateDirectives.ts
Original file line number Diff line number Diff line change
@@ -511,6 +511,17 @@ uiStateDirective = ['$uiRouter', '$timeout',
* </div>
* ```
*
* Arrays are also supported as values in the `ngClass`-like interface.
* This allows multiple states to add `active` class.
*
* #### Example:
* Given the following template, with "admin.roles" being the current state, the class will be added too:
* ```html
* <div ui-sref-active="{'active': ['owner.**', 'admin.**']}">
* <a ui-sref-active="active" ui-sref="admin.roles">Roles</a>
* </div>
* ```
*
* When the current state is "admin.roles" the "active" class will be applied to both the `<div>` and `<a>` elements.
* It is important to note that the state names/globs passed to `ui-sref-active` override any state provided by a linked `ui-sref`.
*
@@ -528,7 +539,7 @@ uiSrefActiveDirective = ['$state', '$stateParams', '$interpolate', '$uiRouter',
restrict: 'A',
controller: ['$scope', '$element', '$attrs',
function ($scope: IScope, $element: IAugmentedJQuery, $attrs: any) {
const states: StateData[] = [];
let states: StateData[] = [];
let activeEqClass: string;
let uiSrefActive: any;

@@ -544,14 +555,7 @@ uiSrefActiveDirective = ['$state', '$stateParams', '$interpolate', '$uiRouter',
// Fall back to using $interpolate below
}
uiSrefActive = uiSrefActive || $interpolate($attrs.uiSrefActive || '', false)($scope);
if (isObject(uiSrefActive)) {
forEach(uiSrefActive, function (stateOrName: StateOrName, activeClass: string) {
if (isString(stateOrName)) {
const ref = parseStateRef(stateOrName);
addState(ref.state, $scope.$eval(ref.paramExpr), activeClass);
}
});
}
setStatesFromDefinitionObject(uiSrefActive);

// Allow uiSref to communicate with uiSrefActive[Equals]
this.$$addStateInfo = function (newState: string, newParams: Obj) {
@@ -568,13 +572,49 @@ uiSrefActiveDirective = ['$state', '$stateParams', '$interpolate', '$uiRouter',
function updateAfterTransition(trans) {
trans.promise.then(update, noop);
}

$scope.$on('$stateChangeSuccess', update);
$scope.$on('$destroy', <any> $uiRouter.transitionService.onStart({}, updateAfterTransition));
$scope.$on('$destroy', setupEventListeners());
if ($uiRouter.globals.transition) {
updateAfterTransition($uiRouter.globals.transition);
}

function setupEventListeners () {
const deregisterStatesChangedListener = $uiRouter.stateRegistry.onStatesChanged(handleStatesChanged);
const deregisterOnStartListener = $uiRouter.transitionService.onStart({}, updateAfterTransition);
const deregisterStateChangeSuccessListener = $scope.$on('$stateChangeSuccess', update);
return function cleanUp () {
deregisterStatesChangedListener();
deregisterOnStartListener();
deregisterStateChangeSuccessListener();
};
}

function handleStatesChanged () {
setStatesFromDefinitionObject(uiSrefActive);
}

function setStatesFromDefinitionObject (statesDefinition: object) {
if (isObject(statesDefinition)) {
states = [];
forEach(statesDefinition, function (stateOrName: StateOrName | Array<StateOrName>, activeClass: string) {
// Helper function to abstract adding state.
const addStateForClass = function (stateOrName: string, activeClass: string) {
const ref = parseStateRef(stateOrName);
addState(ref.state, $scope.$eval(ref.paramExpr), activeClass);
};

if (isString(stateOrName)) {
// If state is string, just add it.
addStateForClass(stateOrName as string, activeClass)
} else if (isArray(stateOrName)) {
// If state is an array, iterate over it and add each array item individually.
forEach(stateOrName, function (stateOrName: string) {
addStateForClass(stateOrName, activeClass)
});
}
});
}
}

function addState(stateName: string, stateParams: Obj, activeClass: string) {
const state = $state.get(stateName, stateContext($element));

5 changes: 0 additions & 5 deletions test/noimplicitany.ts

This file was deleted.

95 changes: 95 additions & 0 deletions test/stateDirectivesSpec.js
Original file line number Diff line number Diff line change
@@ -1056,6 +1056,31 @@ describe('uiSrefActive', function() {
expect(a.attr('class')).toMatch(/active also-active/);
}));

it('should not match fuzzy on lazy loaded future states', inject(function($rootScope, $compile, $q, $state) {
_stateProvider.state('contacts.lazy.**', {
url: '/lazy',
lazyLoad: function() {
return $q.when().then(function() {
_stateProvider.state('contacts.lazy', {
abstract: true,
url: '/lazy'
}).state('contacts.lazy.s1', {
url: '/s1'
}).state('contacts.lazy.s2', {
url: '/s2'
});
});
}
});
template = $compile('<div ui-sref-active="active"><a ui-sref="contacts.lazy.s1">Lazy</a></div><div ui-sref-active="active"><a ui-sref="contacts.lazy.s2"></a></div>')($rootScope);
$rootScope.$digest();
$state.transitionTo('contacts.lazy.s1');
$q.flush();
timeoutFlush();
expect(template.eq(0).hasClass('active')).toBeTruthy();
expect(template.eq(1).hasClass('active')).toBeFalsy();
}));

describe('ng-{class,style} interface', function() {
it('should match on abstract states that are included by the current state', inject(function($rootScope, $compile, $state, $q) {
el = $compile('<div ui-sref-active="{active: \'admin.*\'}"><a ui-sref-active="active" ui-sref="admin.roles">Roles</a></div>')($rootScope);
@@ -1111,5 +1136,75 @@ describe('uiSrefActive', function() {
timeoutFlush();
expect(el.hasClass('active')).toBeTruthy();
}));

it('should not match fuzzy on lazy loaded future states', inject(function($rootScope, $compile, $q, $state) {
_stateProvider.state('contacts.lazy.**', {
url: '/lazy',
lazyLoad: function() {
return $q.when().then(function() {
_stateProvider.state('contacts.lazy', {
abstract: true,
url: '/lazy'
}).state('contacts.lazy.s1', {
url: '/s1'
}).state('contacts.lazy.s2', {
url: '/s2'
});
});
}
});
template = $compile('<div ui-sref-active="{ active: \'contacts.lazy.s1\' }"><a ui-sref="contacts.lazy.s1">Lazy</a></div><div ui-sref-active="{ active: \'contacts.lazy.s2\' }"></div>')($rootScope);
$rootScope.$digest();
$state.transitionTo('contacts.lazy.s1');
$q.flush();
timeoutFlush();
expect(template.eq(0).hasClass('active')).toBeTruthy();
expect(template.eq(1).hasClass('active')).toBeFalsy();
}));
});

describe('ng-{class,style} interface, and handle values as arrays', function() {
it('should match on abstract states that are included by the current state', inject(function($rootScope, $compile, $state, $q) {
el = $compile('<div ui-sref-active="{active: [\'randomState.**\', \'admin.roles\']}"><a ui-sref-active="active" ui-sref="admin.roles">Roles</a></div>')($rootScope);
$state.transitionTo('admin.roles');
$q.flush();
timeoutFlush();
var abstractParent = el[0];
expect(abstractParent.className).toMatch(/active/);
var child = el[0].querySelector('a');
expect(child.className).toMatch(/active/);
}));

it('should match on state parameters', inject(function($compile, $rootScope, $state, $q) {
el = $compile('<div ui-sref-active="{active: [\'admin.roles({page: 1})\']}"></div>')($rootScope);
$state.transitionTo('admin.roles', {page: 1});
$q.flush();
timeoutFlush();
expect(el[0].className).toMatch(/active/);
}));

it('should support multiple <className, stateOrName> pairs', inject(function($compile, $rootScope, $state, $q) {
el = $compile('<div ui-sref-active="{contacts: [\'contacts.item\', \'contacts.item.detail\'], admin: \'admin.roles({page: 1})\'}"></div>')($rootScope);
$state.transitionTo('contacts.item.detail', {id: 1, foo: 'bar'});
$q.flush();
timeoutFlush();
expect(el[0].className).toMatch(/contacts/);
expect(el[0].className).not.toMatch(/admin/);
$state.transitionTo('admin.roles', {page: 1});
$q.flush();
timeoutFlush();
expect(el[0].className).toMatch(/admin/);
expect(el[0].className).not.toMatch(/contacts/);
}));

it('should update the active classes when compiled', inject(function($compile, $rootScope, $document, $state, $q) {
$state.transitionTo('admin.roles');
$q.flush();
timeoutFlush();
el = $compile('<div ui-sref-active="{active: [\'admin.roles\', \'admin.someOtherState\']}"/>')($rootScope);
$rootScope.$digest();
timeoutFlush();
expect(el.hasClass('active')).toBeTruthy();
}));
});
});
Loading