-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(swan): 百度小程序base.swan渲染空白问题修复 #17274
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
Conversation
175640c to
7d0a166
Compare
Walkthrough本次更改在模板处理流程中引入了新的 transformTemplateIsSfor 方法,用于重构同时具有 is 和 s-for 属性的 标签,将其包裹到带 s-for 指令的 中。该转换被集成到多个模板生成与修改方法中,提升了模板结构的一致性。 Changes
Sequence Diagram(s)sequenceDiagram
participant 调用方
participant Template类
调用方->>Template类: buildBaseTemplate/modifyLoopContainer/...
Template类->>Template类: 替换 s-for 模式
Template类->>Template类: transformTemplateIsSfor(模板字符串)
Template类-->>调用方: 返回处理后的模板字符串
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/taro-platform-swan/src/template.ts(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/taro-platform-swan/src/template.ts (1)
packages/taro-platform-swan/src/components.ts (1)
components(3-221)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
🔇 Additional comments (5)
packages/taro-platform-swan/src/template.ts (5)
56-72: 考虑增强正则表达式的健壮性当前的实现对大多数情况有效,但在处理复杂属性值时可能存在边缘情况。例如,如果属性值中包含转义引号或嵌套的表达式,可能会影响匹配的准确性。
建议在后续迭代中考虑使用更健壮的 HTML/XML 解析方法,或增加对复杂属性值的测试覆盖。
50-53: 正确应用了模板转换在基础模板构建过程中集成
transformTemplateIsSfor转换是合理的做法,确保了所有模板都能正确处理is和s-for属性的组合。
197-202: 变量命名一致性改进将循环变量从
item改为i提高了代码的一致性,与文件中其他部分的命名保持一致。
213-215: 为 view 元素添加了显式循环包装将
buildFlattenView()包装在带有s-for的<block>中,与整体的模板转换策略保持一致。这有助于解决百度小程序的渲染问题。建议确保这个更改已经过充分的集成测试,特别是针对复杂的嵌套视图结构。
252-256: 在循环容器修改中集成了模板转换在
modifyLoopContainer的两个分支中都应用了transformTemplateIsSfor,确保了所有循环容器的输出都符合百度小程序的要求。
| } | ||
|
|
||
| createMiniComponents (components): any { | ||
| transformTemplateIsSfor(str) { |
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.
方法参数缺少类型注解
为了保持代码一致性和类型安全,transformTemplateIsSfor 方法的参数应该添加类型注解。
-transformTemplateIsSfor(str) {
+transformTemplateIsSfor(str: string): string {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| transformTemplateIsSfor(str) { | |
| transformTemplateIsSfor(str: string): string { |
🤖 Prompt for AI Agents
In packages/taro-platform-swan/src/template.ts at line 55, the method
transformTemplateIsSfor has a parameter without a type annotation. Add an
appropriate TypeScript type annotation to the parameter to ensure type safety
and maintain code consistency.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17274 +/- ##
========================================
Coverage 59.37% 59.37%
========================================
Files 387 387
Lines 23417 23417
Branches 5126 5144 +18
========================================
Hits 13903 13903
- Misses 8016 8147 +131
+ Partials 1498 1367 -131
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
这个 PR 做了什么? (简要描述所做更改)
百度小程序:修复百度小程序在taro4版本编译渲染空白问题
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
新功能
is和s-for属性的<template>标签重构为外层<block>包裹并携带s-for,提升模板兼容性。优化