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(isNumber): NaN和InFinity在样式和JSON格式化时均不是有效值 #7925

Closed
wants to merge 1 commit into from
Closed

Conversation

SyMind
Copy link
Member

@SyMind SyMind commented Oct 26, 2020

这个 PR 做了什么? (简要描述所做更改)

数据值为 NaN 和 InFinity 时的样式处理错误。

这个 PR 是什么类型? (至少选择一个)

  • 错误修复(Bugfix)

这个 PR 满足以下需求:

  • 提交到 next分支
  • Commit 信息遵循 Angular Style Commit Message Conventions
  • 所有测试用例已经通过
  • 代码遵循相关包中的 .eslintrc, .tslintrc, .stylelintrc 所规定的规范
  • 在本地测试可用,不会影响到其它功能

@SyMind
Copy link
Member Author

SyMind commented Oct 27, 2020

我不清楚导致单元测试错误的原因,恳请求助! @Chen-jj

@Chen-jj
Copy link
Contributor

Chen-jj commented Oct 28, 2020

@SyMind 目测影响了模板的判断

image

对应的模板逻辑在这里,它使用到 isNumber 做判断,你可以调试一下:

} else if (isBooleanStringLiteral(propValue) || isNumber(+propValue)) {
propValue = this.supportXS
? `xs.b(i.${toCamelCase(prop)},${propValue})`
: `i.${toCamelCase(prop)}===undefined?${propValue}:i.${toCamelCase(prop)}`

@SyMind
Copy link
Member Author

SyMind commented Oct 28, 2020

@Chen-jj 感谢帮助。我想当前的渲染结果才是符合预期的,对于 number 或 boolean 属性使用 a === undefined ? b : a 进行判断,string 属性使用 a || b 来判断。

而现在 snapshot 中在转换过程中由于 (+'') === 0 导致将初始值为空字符串的 string 类型当做 number 类型来处理了。

我将更新 snapshot。

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.

2 participants