Skip to content
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

Merged
merged 3 commits into from
Jul 18, 2019

Conversation

monkindey
Copy link
Contributor

closes: #177

调整下获取全局变量的优先级,不然 this 在 webpack 打包的时候运行时会变成 module

@@ -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 = [
Copy link
Contributor

@stkevintan stkevintan Jul 18, 2019

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了

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是在哪里的 else if 呢?

@monkindey
Copy link
Contributor Author

@stkevintan 我先 merge 了,因为这个涉及的影响有点多,算是比较紧急的问题。后面要是有问题再说,特别是 ts 的话可以新开另外一个 PR哈。

@monkindey monkindey merged commit 4ef2e1c into alibaba:master Jul 18, 2019
@monkindey monkindey deleted the correct-self branch July 18, 2019 03:32
ZirkleTsing pushed a commit that referenced this pull request May 14, 2020
* fix(utils): adjust the order of getting self

* refactor: imitate globalThis

* refactor: polyfill globalThis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

this 指针结合 webpack 构建出现问题
2 participants