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(template): prevent default values from overriding props #17167

Merged
merged 5 commits into from
Feb 28, 2025

Conversation

erweixin
Copy link
Contributor

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

当默认值为 true 时,props value 设置为 false 不会生效

原代码类似:

const props = props.value || true

更改为

const props = props.value !==  undefined ? props.value : true

没有使用 ?? 是因为小程序暂时不支持,使用需要项目转为 es5。

const props = props.value ?? true

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

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)
  • 鸿蒙(harmony)

@erweixin
Copy link
Contributor Author

之前不会走到这个逻辑分支是因为前面有个 isBooleanStringLiteral 判断,使用 'true''false', video 的默认 props 改成了 !0'!1'。所以更改 isBooleanStringLiteral 的判断逻辑也能解决。

This was referenced Jan 11, 2025
Copy link
Member

@tutuxxx tutuxxx left a comment

Choose a reason for hiding this comment

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

感谢贡献。o is string -> o is boolean,这个改动是什么原因 @erweixin

@tutuxxx tutuxxx added this to the 4.0.10 milestone Feb 27, 2025
@erweixin
Copy link
Contributor Author

感谢贡献。o is string -> o is boolean,这个改动是什么原因 @erweixin

这个是不需要更改。修正了。

@tutuxxx
Copy link
Member

tutuxxx commented Feb 28, 2025

@erweixin
Copy link
Contributor Author

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.52%. Comparing base (f180604) to head (41a9808).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #17167    +/-   ##
========================================
  Coverage   58.52%   58.52%            
========================================
  Files         468      468            
  Lines       27136    27136            
  Branches     5939     5712   -227     
========================================
  Hits        15882    15882            
+ Misses       9802     9771    -31     
- Partials     1452     1483    +31     
Flag Coverage Δ
taro-cli 72.37% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 52.77% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 15 files with indirect coverage changes

@tutuxxx tutuxxx self-requested a review February 28, 2025 11:34
@tutuxxx tutuxxx merged commit f9a84d1 into NervJS:main Feb 28, 2025
23 checks passed
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.

[BUG] Video 组件的 controls 等属性无效 Taro 4.0.7 Video 无法控制 controls 不展示
2 participants