Skip to content

fix: 将无值的属性在输出RN时视为true#2486

Open
mackwang112 wants to merge 1 commit into
masterfrom
fix/react-boolean-attr-codegen
Open

fix: 将无值的属性在输出RN时视为true#2486
mackwang112 wants to merge 1 commit into
masterfrom
fix/react-boolean-attr-codegen

Conversation

@mackwang112
Copy link
Copy Markdown
Collaborator

在输出RN编译模板时,未指定值的属性(例如<scroll-view scroll-y>)其值被解析为 {"scroll-y": undefined}
现在,此类属性在生成的渲染函数中正确地处理为 {"scroll-y": true} (等价于<scroll-view scroll-y="{{ true}}">),与小程序布尔属性语义对齐。

具有显式值的属性(例如scroll-y="{{undefined}}")保持不变。

When compiling templates for React/RN, attributes written without a
value (e.g. <scroll-view scroll-y>) had their value parsed as
undefined, which JSON.stringify silently drops. Now such attributes
correctly emit `true` in the generated render function, matching
miniprogram boolean-attribute semantics.

Attributes with an explicit value (e.g. scroll-y="{{undefined}}") are
unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mackwang112 mackwang112 changed the title fix(react): treat valueless boolean attrs as true in codegen fix: 将无值的属性在输出RN时视为true May 12, 2026
@mackwang112 mackwang112 added bug Something isn't working platform:RN Mpx 跨端输出 RN labels May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working platform:RN Mpx 跨端输出 RN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant