-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(utils): adjust the order of getting self #178
Conversation
@@ -2,7 +2,8 @@ import { isFn } from '@uform/types' | |||
|
|||
type Filter = (value: any, key: string) => boolean | |||
|
|||
const self: { [key: string]: any } = window || global || this | |||
const _self: { [key: string]: any } = | |||
self || window || global || Function('return this')() | |||
|
|||
const NATIVE_KEYS = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NATIVE_KEYS: [string, (obj: any) => any][] = [xxxx]
下面就不用as了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好像这样子也是不行的哦,他是有 string 类型的
NATIVE_KEYS: ([string, (obj: any) => any] | string)[] = [xxxx]
这样子解有点问题,下面去掉 as string ,也是会报错。
self[item[0] as string] && | ||
values instanceof self[item[0] as string] | ||
_self[item[0] as string] && | ||
values instanceof _self[item[0] as string] | ||
) { | ||
return item[1] ? item[1] : item[0] | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是在哪里的 else if 呢?
@stkevintan 我先 merge 了,因为这个涉及的影响有点多,算是比较紧急的问题。后面要是有问题再说,特别是 ts 的话可以新开另外一个 PR哈。 |
* fix(utils): adjust the order of getting self * refactor: imitate globalThis * refactor: polyfill globalThis
closes: #177
调整下获取全局变量的优先级,不然 this 在 webpack 打包的时候运行时会变成 module