Skip to content

Commit 9c94c2a

Browse files
authored
fix(stateParams): $inherit is not affected by enumerable prototype custom methods (#841)
1 parent 77b549c commit 9c94c2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1360
-2568
lines changed

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@v2
2424
- uses: actions/setup-node@v3
2525
with:
26-
node-version: 16
26+
node-version: 18
2727
- name: Install Dependencies
2828
run: yarn install --pure-lockfile
2929
- name: Check Peer Dependencies
@@ -42,7 +42,6 @@ jobs:
4242
- uses: actions/checkout@v2
4343
- name: Prepare to Test Downstream Projects
4444
run: |
45-
npm config set scripts-prepend-node-path auto
4645
git config --global user.email [email protected]
4746
git config --global user.name uirouter_github_actions
4847
- name: Install Dependencies

downstream_projects.json

+1-16
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,8 @@
99
"react": "https://github.com/ui-router/react.git"
1010
},
1111
"other": {
12+
"typescript5.4": "./test/typescript5.4",
1213
"typescript3.9": "./test/typescript3.9",
13-
"typescript3.8": "./test/typescript3.8",
14-
"typescript3.7": "./test/typescript3.7",
15-
"typescript3.6": "./test/typescript3.6",
16-
"typescript3.5": "./test/typescript3.5",
17-
"typescript3.4": "./test/typescript3.4",
18-
"typescript3.3": "./test/typescript3.3",
19-
"typescript3.2": "./test/typescript3.2",
20-
"typescript3.1": "./test/typescript3.1",
21-
"typescript3.0": "./test/typescript3.0",
22-
"typescript2.8": "./test/typescript2.8",
23-
"typescript2.7": "./test/typescript2.7",
24-
"typescript2.6": "./test/typescript2.6",
25-
"typescript2.5": "./test/typescript2.5",
26-
"typescript2.4": "./test/typescript2.4",
27-
"typescript2.3": "./test/typescript2.3",
28-
"typescript2.2": "./test/typescript2.2",
2914
"sticky-states": "https://github.com/ui-router/sticky-states.git"
3015
}
3116
}

package.json

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@uirouter/core",
33
"description": "UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps",
4-
"version": "6.1.0",
4+
"version": "6.1.1",
55
"scripts": {
66
"clean": "shx rm -rf lib lib-esm _bundles .cache _doc",
77
"compile": "npm run clean && tsc && tsc -m es6 --outDir lib-esm",
@@ -66,33 +66,34 @@
6666
"module": "lib-esm/index.js",
6767
"license": "MIT",
6868
"devDependencies": {
69-
"@types/jasmine": "^3.3.13",
69+
"@types/jasmine": "^5.1.4",
7070
"@types/jquery": "^3.3.36",
71-
"@uirouter/publish-scripts": "^2.6.0",
71+
"@uirouter/publish-scripts": "^2.6.3",
7272
"bufferutil": "4.0.2",
7373
"dts-downlevel": "^0.4.0",
74-
"fork-ts-checker-webpack-plugin": "^6.0.8",
74+
"fork-ts-checker-webpack-plugin": "^9.0.2",
7575
"husky": "^4.2.5",
7676
"jasmine-core": "^3.3.0",
7777
"karma": "^5.0.4",
7878
"karma-chrome-launcher": "^3.1.0",
7979
"karma-firefox-launcher": "^2.1.0",
8080
"karma-jasmine": "^4.0.1",
8181
"karma-script-launcher": "^1.0.0",
82-
"karma-sourcemap-loader": "^0.3.7",
83-
"karma-webpack": "^4.0.2",
82+
"karma-sourcemap-loader": "^0.4.0",
83+
"karma-webpack": "^5.0.1",
84+
"eslint": "^8.57.0",
85+
"@typescript-eslint/parser": "^7.16.0",
86+
"@typescript-eslint/eslint-plugin": "^7.16.0",
8487
"prettier": "^2.0.5",
8588
"pretty-quick": "^3.1.0",
8689
"rollup": "1.32.1",
8790
"rollup-plugin-node-resolve": "^5.0.2",
8891
"rollup-plugin-sourcemaps": "^0.6.1",
8992
"rollup-plugin-uglify": "^6.0.0",
9093
"ts-loader": "^8.0.12",
91-
"tslint": "5.20.1",
92-
"tslint-eslint-rules": "^5.3.1",
93-
"typescript": "~3.9",
94+
"typescript": "~5.4.5",
9495
"utf-8-validate": "5.0.3",
95-
"webpack": "^4.34.0"
96+
"webpack": "^5.92.1"
9697
},
9798
"resolutions": {
9899
"chokidar": "3.3.1"
@@ -122,5 +123,6 @@
122123
"Trace"
123124
]
124125
}
125-
}
126+
},
127+
"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
126128
}

src/common/coreservices.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const noImpl = (fnname: string) => () => {
1313
};
1414

1515
export const makeStub = <T>(service: string, methods: (keyof T)[]): T =>
16-
methods.reduce((acc, key) => ((acc[key] = noImpl(`${service}.${key}()`) as any), acc), {} as T);
16+
methods.reduce((acc, key) => ((acc[key] = noImpl(`${service}.${String(key)}()`) as any), acc), {} as T);
1717

1818
const services: CoreServices = {
1919
$q: undefined,

src/common/hof.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ export const parse = (name: string) => pipe.apply(null, name.split('.').map(prop
116116
* Given a function that returns a truthy or falsey value, returns a
117117
* function that returns the opposite (falsey or truthy) value given the same inputs
118118
*/
119-
export const not: (fn: Predicate<any>) => Predicate<any> = (fn: Predicate<any>) => (...args: any[]) =>
120-
!fn.apply(null, args);
119+
export const not: (fn: Predicate<any>) => Predicate<any> =
120+
(fn: Predicate<any>) =>
121+
(...args: any[]) =>
122+
!fn.apply(null, args);
121123

122124
/**
123125
* Given two functions that return truthy or falsey values, returns a function that returns truthy
@@ -147,14 +149,19 @@ export const all = (fn1: Predicate<any>) => (arr: any[]) => arr.reduce((b, x) =>
147149
export const any = (fn1: Predicate<any>) => (arr: any[]) => arr.reduce((b, x) => b || !!fn1(x), false) as boolean;
148150

149151
/** Given a class, returns a Predicate function that returns true if the object is of that class */
150-
export const is = <T>(ctor: { new (...args): T }) => (obj: any): obj is T =>
151-
(obj != null && obj.constructor === ctor) || obj instanceof ctor;
152+
export const is =
153+
<T>(ctor: { new (...args: any[]): T }) =>
154+
(obj: any): obj is T =>
155+
(obj != null && obj.constructor === ctor) || obj instanceof ctor;
152156

153157
/** Given a value, returns a Predicate function that returns true if another value is === equal to the original value */
154158
export const eq: (comp: any) => Predicate<any> = (value: any) => (other: any) => value === other;
155159

156160
/** Given a value, returns a function which returns the value */
157-
export const val = <T>(v: T) => () => v;
161+
export const val =
162+
<T>(v: T) =>
163+
() =>
164+
v;
158165

159166
export function invoke(fnName: string): Function;
160167
export function invoke(fnName: string, args: any[]): Function;

src/params/stateParams.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ export class StateParams {
2929
if (!parentParamsKeys.length) continue;
3030

3131
for (const j in parentParamsKeys) {
32-
if (parentParams[parentParamsKeys[j]].inherit == false || inheritList.indexOf(parentParamsKeys[j]) >= 0)
32+
if (
33+
!parentParamsKeys.hasOwnProperty(j) ||
34+
parentParams[parentParamsKeys[j]].inherit == false ||
35+
inheritList.indexOf(parentParamsKeys[j]) >= 0
36+
)
3337
continue;
3438
inheritList.push(parentParamsKeys[j]);
3539
inherited[parentParamsKeys[j]] = this[parentParamsKeys[j]];

0 commit comments

Comments
 (0)