Skip to content

Commit

Permalink
fix(stateParams): $inherit is not affected by enumerable prototype cu…
Browse files Browse the repository at this point in the history
…stom methods (#841)
  • Loading branch information
wawyed authored Jul 15, 2024
1 parent 77b549c commit 9c94c2a
Show file tree
Hide file tree
Showing 56 changed files with 1,360 additions and 2,568 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Install Dependencies
run: yarn install --pure-lockfile
- name: Check Peer Dependencies
Expand All @@ -42,7 +42,6 @@ jobs:
- uses: actions/checkout@v2
- name: Prepare to Test Downstream Projects
run: |
npm config set scripts-prepend-node-path auto
git config --global user.email uirouter@github.actions
git config --global user.name uirouter_github_actions
- name: Install Dependencies
Expand Down
17 changes: 1 addition & 16 deletions downstream_projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,8 @@
"react": "https://github.com/ui-router/react.git"
},
"other": {
"typescript5.4": "./test/typescript5.4",
"typescript3.9": "./test/typescript3.9",
"typescript3.8": "./test/typescript3.8",
"typescript3.7": "./test/typescript3.7",
"typescript3.6": "./test/typescript3.6",
"typescript3.5": "./test/typescript3.5",
"typescript3.4": "./test/typescript3.4",
"typescript3.3": "./test/typescript3.3",
"typescript3.2": "./test/typescript3.2",
"typescript3.1": "./test/typescript3.1",
"typescript3.0": "./test/typescript3.0",
"typescript2.8": "./test/typescript2.8",
"typescript2.7": "./test/typescript2.7",
"typescript2.6": "./test/typescript2.6",
"typescript2.5": "./test/typescript2.5",
"typescript2.4": "./test/typescript2.4",
"typescript2.3": "./test/typescript2.3",
"typescript2.2": "./test/typescript2.2",
"sticky-states": "https://github.com/ui-router/sticky-states.git"
}
}
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@uirouter/core",
"description": "UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps",
"version": "6.1.0",
"version": "6.1.1",
"scripts": {
"clean": "shx rm -rf lib lib-esm _bundles .cache _doc",
"compile": "npm run clean && tsc && tsc -m es6 --outDir lib-esm",
Expand Down Expand Up @@ -66,33 +66,34 @@
"module": "lib-esm/index.js",
"license": "MIT",
"devDependencies": {
"@types/jasmine": "^3.3.13",
"@types/jasmine": "^5.1.4",
"@types/jquery": "^3.3.36",
"@uirouter/publish-scripts": "^2.6.0",
"@uirouter/publish-scripts": "^2.6.3",
"bufferutil": "4.0.2",
"dts-downlevel": "^0.4.0",
"fork-ts-checker-webpack-plugin": "^6.0.8",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"husky": "^4.2.5",
"jasmine-core": "^3.3.0",
"karma": "^5.0.4",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-jasmine": "^4.0.1",
"karma-script-launcher": "^1.0.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "^5.0.1",
"eslint": "^8.57.0",
"@typescript-eslint/parser": "^7.16.0",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"prettier": "^2.0.5",
"pretty-quick": "^3.1.0",
"rollup": "1.32.1",
"rollup-plugin-node-resolve": "^5.0.2",
"rollup-plugin-sourcemaps": "^0.6.1",
"rollup-plugin-uglify": "^6.0.0",
"ts-loader": "^8.0.12",
"tslint": "5.20.1",
"tslint-eslint-rules": "^5.3.1",
"typescript": "~3.9",
"typescript": "~5.4.5",
"utf-8-validate": "5.0.3",
"webpack": "^4.34.0"
"webpack": "^5.92.1"
},
"resolutions": {
"chokidar": "3.3.1"
Expand Down Expand Up @@ -122,5 +123,6 @@
"Trace"
]
}
}
},
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
}
2 changes: 1 addition & 1 deletion src/common/coreservices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const noImpl = (fnname: string) => () => {
};

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

const services: CoreServices = {
$q: undefined,
Expand Down
17 changes: 12 additions & 5 deletions src/common/hof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ export const parse = (name: string) => pipe.apply(null, name.split('.').map(prop
* Given a function that returns a truthy or falsey value, returns a
* function that returns the opposite (falsey or truthy) value given the same inputs
*/
export const not: (fn: Predicate<any>) => Predicate<any> = (fn: Predicate<any>) => (...args: any[]) =>
!fn.apply(null, args);
export const not: (fn: Predicate<any>) => Predicate<any> =
(fn: Predicate<any>) =>
(...args: any[]) =>
!fn.apply(null, args);

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

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

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

/** Given a value, returns a function which returns the value */
export const val = <T>(v: T) => () => v;
export const val =
<T>(v: T) =>
() =>
v;

export function invoke(fnName: string): Function;
export function invoke(fnName: string, args: any[]): Function;
Expand Down
6 changes: 5 additions & 1 deletion src/params/stateParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export class StateParams {
if (!parentParamsKeys.length) continue;

for (const j in parentParamsKeys) {
if (parentParams[parentParamsKeys[j]].inherit == false || inheritList.indexOf(parentParamsKeys[j]) >= 0)
if (
!parentParamsKeys.hasOwnProperty(j) ||
parentParams[parentParamsKeys[j]].inherit == false ||
inheritList.indexOf(parentParamsKeys[j]) >= 0
)
continue;
inheritList.push(parentParamsKeys[j]);
inherited[parentParamsKeys[j]] = this[parentParamsKeys[j]];
Expand Down
Loading

0 comments on commit 9c94c2a

Please sign in to comment.