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.27
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.28
Choose a head ref
  • 10 commits
  • 19 files changed
  • 3 contributors

Commits on Jul 21, 2020

  1. Copy the full SHA
    b70a45f View commit details

Commits on Jul 26, 2020

  1. Copy the full SHA
    f52d49c View commit details
  2. refactor(lint): Migrate from tslint to eslint using npx tslint-to-esl…

    …int-config --prettier --comments **/*.ts
    christopherthielen authored and mergify[bot] committed Jul 26, 2020
    Copy the full SHA
    c159363 View commit details
  3. Copy the full SHA
    07775e2 View commit details
  4. Copy the full SHA
    60308d1 View commit details
  5. Copy the full SHA
    e21d358 View commit details
  6. Copy the full SHA
    6583584 View commit details
  7. Copy the full SHA
    c1d9551 View commit details

Commits on Aug 8, 2020

  1. fix: should not transition states when alt-clicked

    In most browsers, clicking links with the Alt key has a special behavior, for example, Chrome
    downloads the target resource. As with other modifier keys, the router should stop the original
    navigation to avoid preventing the browser’s default behavior.
    
    When users click a link while holding the Alt key together, the browsers behave as follows.
    
    Windows 10:
    
    | Browser    | Behavior                                    |
    |:-----------|:--------------------------------------------|
    | Chrome 84  | Download the target resource                |
    | Firefox 79 | Prevent navigation and therefore do nothing |
    | Edge 84    | Download the target resource                |
    | IE 11      | No impact                                   |
    
    macOS Catalina:
    
    | Browser    | Behavior                                    |
    |:-----------|:--------------------------------------------|
    | Chrome 84  | Download the target resource                |
    | Firefox 79 | Prevent navigation and therefore do nothing |
    | Safari 13  | Download the target resource                |
    yuheiy authored and christopherthielen committed Aug 8, 2020
    Copy the full SHA
    8080adb View commit details
  2. 1.0.28

    christopherthielen committed Aug 8, 2020
    Copy the full SHA
    f9bbea4 View commit details
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// eslint-disable-next-line no-undef
module.exports = {
env: { browser: true },
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'prettier/@typescript-eslint'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',

'@typescript-eslint/ban-types': [
'error',
{
types: {
Function: false,
},
},
],
},
};
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ bower.json
karma.conf.js
tsconfig.json
tsconfig.**.json
tslint.json
webpack.config.js

*.iml
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.0.28 (2020-08-08)
[Compare `@uirouter/angularjs` versions 1.0.27 and 1.0.28](https://github.com/angular-ui/ui-router/compare/1.0.27...1.0.28)

### Bug Fixes

* should not transition states when alt-clicked ([8080adb](https://github.com/angular-ui/ui-router/commit/8080adb))

## 1.0.27 (2020-07-21)
[Compare `@uirouter/angularjs` versions 1.0.26 and 1.0.27](https://github.com/angular-ui/ui-router/compare/1.0.26...1.0.27)

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.26"
"version": "1.0.27"
}
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "@uirouter/angularjs",
"description": "State-based routing for AngularJS 1.x",
"version": "1.0.27",
"version": "1.0.28",
"scripts": {
"clean": "shx rm -rf lib lib-esm _doc build release *.log",
"compile": "tsc && tsc -m es6 --outDir lib-esm && npm run fixdts",
"fixdts": "dts-downlevel 'lib/**/*.d.ts' 'lib-esm/**/*.d.ts'",
"fixmaps:lib": "tweak_sourcemap_paths -a --include 'lib/**/*.js.map' 'lib-esm/**/*.js.map'",
"fixmaps:bundle": "tweak_sourcemap_paths -a --include 'release/**/*.js.map'",
"build": "npm run clean && npm run compile && npm run bundle && npm run fixmaps:lib && npm run fixmaps:bundle",
"lint": "eslint src/**/*.ts",
"package": "npm run build",
"bundle": "npm run bundle_router && npm run bundle_monolithic_router && npm run bundle_events && npm run bundle_resolve",
"bundle_monolithic_router": "rollup -c --environment ROUTER,MONOLITHIC && rollup -c --environment ROUTER,MINIFY,MONOLITHIC",
@@ -84,11 +85,15 @@
"@types/angular-animate": "^1.5.10",
"@types/angular-mocks": "^1.7.0",
"@types/jest": "^26.0.5",
"@typescript-eslint/eslint-plugin": "^3.7.0",
"@typescript-eslint/parser": "^3.7.0",
"@uirouter/publish-scripts": "2.5.3",
"angular": "1.8.0",
"bufferutil": "4.0.1",
"canvas": "2.6.1",
"dts-downlevel": "^0.4.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"husky": "^4.2.5",
"jest": "^26.0.1",
"lodash": "^4.17.19",
@@ -99,8 +104,6 @@
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^6.1.0",
"ts-jest": "^26.0.0",
"tslint": "5.20.1",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^3.9.7",
"utf-8-validate": "5.0.2"
},
@@ -129,7 +132,8 @@
"Components": [
"uiView",
"UISref",
"UISrefActive"
"UISrefActive",
"uiStateDirective"
],
"Other": [
"Transition",
2 changes: 1 addition & 1 deletion src/angular.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @publicapi @module ng1 */ /** */
import * as ng_from_import from 'angular';
/** @hidden */ declare var angular;
/** @hidden */ declare let angular;
/** @hidden */ const ng_from_global = angular;
/** @hidden */ export const ng = ng_from_import && ng_from_import.module ? ng_from_import : ng_from_global;
14 changes: 7 additions & 7 deletions src/directives/stateDirectives.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
/* eslint-disable prefer-const */
/**
* # Angular 1 Directives
*
@@ -34,15 +36,14 @@ import {
import { UIViewData } from './viewDirective';

/** @hidden Used for typedoc */
export interface ng1_directive {} // tslint:disable-line:class-name
export interface ng1_directive {}

/** @hidden */
function parseStateRef(ref: string) {
let parsed;
const paramsOnly = ref.match(/^\s*({[^}]*})\s*$/);
if (paramsOnly) ref = '(' + paramsOnly[1] + ')';

parsed = ref.replace(/\n/g, ' ').match(/^\s*([^(]*?)\s*(\((.*)\))?\s*$/);
const parsed = ref.replace(/\n/g, ' ').match(/^\s*([^(]*?)\s*(\((.*)\))?\s*$/);
if (!parsed || parsed.length !== 4) throw new Error("Invalid state ref '" + ref + "'");
return { state: parsed[1] || null, paramExpr: parsed[3] || null };
}
@@ -94,7 +95,7 @@ function clickHook(
const button = e.which || e.button,
target = getDef();

if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || el.attr('target'))) {
if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || el.attr('target'))) {
// HACK: This is to allow ng-clicks to be processed before the transition is initiated:
const transition = $timeout(function () {
if (!el.attr('disabled')) {
@@ -294,7 +295,6 @@ uiSrefDirective = [
const type = getTypeInfo(element);
const active = uiSrefActive[1] || uiSrefActive[0];
let unlinkInfoFn: Function = null;
let hookFn;

const rawDef = {} as Def;
const getDef = () => processedDef($state, element, rawDef);
@@ -328,7 +328,7 @@ uiSrefDirective = [
scope.$on('$destroy', <any>$uiRouter.transitionService.onSuccess({}, update));

if (!type.clickable) return;
hookFn = clickHook(element, $state, $timeout, type, getDef);
const hookFn = clickHook(element, $state, $timeout, type, getDef);
bindEvents(element, scope, hookFn, rawDef.uiStateOpts);
},
};
@@ -641,7 +641,7 @@ uiSrefActiveDirective = [
setStatesFromDefinitionObject(uiSrefActive);
}

function setStatesFromDefinitionObject(statesDefinition: object) {
function setStatesFromDefinitionObject(statesDefinition: Obj) {
if (isObject(statesDefinition)) {
states = [];
forEach(statesDefinition, function (stateOrName: StateOrName | Array<StateOrName>, activeClass: string) {
20 changes: 8 additions & 12 deletions src/directives/viewDirective.ts
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ import {
unnestR,
ViewService,
} from '@uirouter/core';
import { IAugmentedJQuery, IInterpolateService, IScope, ITimeoutService, ITranscludeFunction } from 'angular';
import { IAugmentedJQuery, IInterpolateService, IScope, ITranscludeFunction } from 'angular';
import { ng as angular } from '../angular';
import { Ng1Controller, Ng1StateDeclaration } from '../interface';
import { getLocals } from '../services';
@@ -170,6 +170,7 @@ export type UIViewAnimData = {
* ```
*/
export let uiView: ng1_directive;
// eslint-disable-next-line prefer-const
uiView = [
'$view',
'$animate',
@@ -183,7 +184,7 @@ uiView = [
$interpolate: IInterpolateService,
$q: $QLike
) {
function getRenderer(attrs: Obj, scope: IScope) {
function getRenderer() {
return {
enter: function (element: JQuery, target: any, cb: Function) {
if (angular.version.minor > 2) {
@@ -221,15 +222,11 @@ uiView = [
return function (scope: IScope, $element: IAugmentedJQuery, attrs: Obj) {
const onloadExp = attrs['onload'] || '',
autoScrollExp = attrs['autoscroll'],
renderer = getRenderer(attrs, scope),
renderer = getRenderer(),
inherited = $element.inheritedData('$uiView') || rootData,
name = $interpolate(attrs['uiView'] || attrs['name'] || '')(scope) || '$default';

let previousEl: JQuery,
currentEl: JQuery,
currentScope: IScope,
viewConfig: Ng1ViewConfig,
unregister: Function;
let previousEl: JQuery, currentEl: JQuery, currentScope: IScope, viewConfig: Ng1ViewConfig;

const activeUIView: ActiveUIView = {
$type: 'ng1',
@@ -263,7 +260,7 @@ uiView = [

updateView();

unregister = $view.registerUIView(activeUIView);
const unregister = $view.registerUIView(activeUIView);
scope.$on('$destroy', function () {
trace.traceUIViewEvent('Destroying/Unregistering', activeUIView);
unregister();
@@ -363,16 +360,15 @@ uiView = [
},
];

$ViewDirectiveFill.$inject = ['$compile', '$controller', '$transitions', '$view', '$q', '$timeout'];
$ViewDirectiveFill.$inject = ['$compile', '$controller', '$transitions', '$view', '$q'];

/** @hidden */
function $ViewDirectiveFill(
$compile: angular.ICompileService,
$controller: angular.IControllerService,
$transitions: TransitionService,
$view: ViewService,
$q: angular.IQService,
$timeout: ITimeoutService
$q: angular.IQService
) {
const getControllerAs = parse('viewDecl.controllerAs');
const getResolveAs = parse('viewDecl.resolveAs');
2 changes: 1 addition & 1 deletion src/injectables.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* # Angular 1 injectable services
*
@@ -48,7 +49,6 @@
*
* @preferred @publicapi @module injectables
*/ /** */
/* tslint:disable:prefer-const */
import { StateProvider } from './stateProvider';
import {
StateService,
1 change: 0 additions & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
@@ -50,7 +50,6 @@ export interface Ng1StateTransitionHook {
*
* Used to reset [[StateDeclaration]] typings to `any` so the [[Ng1StateDeclaration]] interface can then narrow them */
export interface _Ng1StateDeclaration extends StateDeclaration {
// tslint:disable-line:class-name
onExit?: any;
onRetain?: any;
onEnter?: any;
1 change: 1 addition & 0 deletions src/legacy/stateEvents.ts
Original file line number Diff line number Diff line change
@@ -341,6 +341,7 @@ export let $stateNotFound: IAngularEvent;
.provider('$stateEvents', ($StateEventsProvider as any) as IServiceProviderFactory)
.run([
'$stateEvents',
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function ($stateEvents: any) {
/* Invokes $get() */
},
1 change: 1 addition & 0 deletions src/locationServices.ts
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ export class Ng1LocationServices implements LocationConfig, LocationServices {
x != null ? x.toString().replace(/(~~|~2F)/g, (m) => ({ '~~': '~', '~2F': '/' }[m])) : x;
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
dispose() {}

constructor($locationProvider: ILocationProvider) {
9 changes: 5 additions & 4 deletions src/services.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* # Angular 1 types
*
@@ -37,19 +39,18 @@ import { StateProvider } from './stateProvider';
import { getStateHookBuilder } from './statebuilders/onEnterExitRetain';
import { Ng1LocationServices } from './locationServices';
import { UrlRouterProvider } from './urlRouterProvider';
import IInjectorService = angular.auto.IInjectorService; // tslint:disable-line
import IInjectorService = angular.auto.IInjectorService;

angular.module('ui.router.angular1', []);
const mod_init = angular.module('ui.router.init', ['ng']);
const mod_util = angular.module('ui.router.util', ['ui.router.init']);
const mod_rtr = angular.module('ui.router.router', ['ui.router.util']);
const mod_state = angular.module('ui.router.state', ['ui.router.router', 'ui.router.util', 'ui.router.angular1']);
const mod_main = angular.module('ui.router', ['ui.router.init', 'ui.router.state', 'ui.router.angular1']);
const mod_cmpt = angular.module('ui.router.compat', ['ui.router']); // tslint:disable-line
const mod_cmpt = angular.module('ui.router.compat', ['ui.router']);

declare module '@uirouter/core/lib/router' {
interface UIRouter {
// tslint:disable-line:no-shadowed-variable
/** @hidden */
stateProvider: StateProvider;
/** @hidden */
@@ -120,7 +121,7 @@ function runBlock($injector: IInjectorService, $q: IQService, $uiRouter: UIRoute
services.$q = <any>$q;

// https://github.com/angular-ui/ui-router/issues/3678
if (!$injector.hasOwnProperty('strictDi')) {
if (!Object.prototype.hasOwnProperty.call($injector, 'strictDi')) {
try {
$injector.invoke(function (checkStrictDi) {});
} catch (error) {
3 changes: 1 addition & 2 deletions src/statebuilders/onEnterExitRetain.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ import {
services,
ResolveContext,
extend,
BuilderFunction,
} from '@uirouter/core';
import { getLocals } from '../services';
import { Ng1StateDeclaration } from '../interface';
@@ -22,7 +21,7 @@ import { Ng1StateDeclaration } from '../interface';
* @internalapi
*/
export const getStateHookBuilder = (hookName: 'onEnter' | 'onExit' | 'onRetain') =>
function stateHookBuilder(stateObject: StateObject, parentFn: BuilderFunction): TransitionStateHookFn {
function stateHookBuilder(stateObject: StateObject): TransitionStateHookFn {
const hook = stateObject[hookName];
const pathname = hookName === 'onExit' ? 'from' : 'to';

2 changes: 0 additions & 2 deletions src/statebuilders/views.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @publicapi @module ng1 */ /** */
import { ng as angular } from '../angular';
import {
StateObject,
pick,
@@ -22,7 +21,6 @@ import {
} from '@uirouter/core';
import { Ng1ViewDeclaration } from '../interface';
import { TemplateFactory } from '../templateFactory';
import IInjectorService = angular.auto.IInjectorService;

/** @internalapi */
export function getNg1ViewConfigFactory(): ViewConfigFactory {
6 changes: 3 additions & 3 deletions src/urlRouterProvider.ts
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ export interface RawNg1RuleFunction {
* @deprecated
*/
export class UrlRouterProvider {
static injectableHandler(router: UIRouter, handler): UrlRuleHandlerFn {
static injectableHandler(router: UIRouter, handler: IInjectable): UrlRuleHandlerFn {
return (match) => services.$injector.invoke(handler, null, { $match: match, $stateParams: router.globals.params });
}

@@ -164,7 +164,7 @@ export class UrlRouterProvider {
*
* Note: the handler may also invoke arbitrary code, such as `$state.go()`
*/
when(what: RegExp | UrlMatcher | string, handler: string | IInjectable) {
when(what: RegExp | UrlMatcher | string, handler: string | IInjectable): this {
if (isArray(handler) || isFunction(handler)) {
handler = UrlRouterProvider.injectableHandler(this.router, handler);
}
@@ -203,7 +203,7 @@ export class UrlRouterProvider {
* @param defer Indicates whether to defer location change interception.
* Passing no parameter is equivalent to `true`.
*/
deferIntercept(defer?: boolean) {
deferIntercept(defer?: boolean): void {
this.router.urlService.deferIntercept(defer);
}
}
12 changes: 12 additions & 0 deletions test/stateDirectivesSpec.ts
Original file line number Diff line number Diff line change
@@ -232,6 +232,18 @@ describe('uiStateRef', function () {
expect(obj($stateParams)).toEqual({});
}));

it('should not transition states when alt-clicked', inject(function ($state, $stateParams, $q) {
expect($state.$current.name).toEqual('top');
expect(obj($stateParams)).toEqual({});

triggerClick(el, { altKey: true });
timeoutFlush();
$q.flush();

expect($state.current.name).toEqual('top');
expect(obj($stateParams)).toEqual({});
}));

it('should not transition states when middle-clicked', inject(function ($state, $stateParams, $q) {
expect($state.$current.name).toEqual('top');
expect(obj($stateParams)).toEqual({});
Loading