-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(uni-mp-compiler): wxs方法支持变量作为参数 #4905
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
base: next
Are you sure you want to change the base?
Conversation
感谢提供 PR,已在 review |
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.
Pull Request Overview
This PR fixes the issue of supporting variables as parameters in wxs methods by updating the filter transformation logic.
- Added a new code block to handle filter expressions by extracting and rewriting parameters.
- Introduced error handling for unsupported argument types in the parameter extraction.
Comments suppressed due to low confidence (1)
packages/uni-mp-compiler/src/transforms/transformIdentifier.ts:77
- Add validation to confirm that both '(' and ')' exist in contentStr before using them to extract parameters.
const paramStr = contentStr.substring(contentStr.indexOf('(') + 1, contentStr.indexOf(')'))
} | ||
}) | ||
.join('') | ||
const lhs = contentStr.substring(0, contentStr.indexOf('(')) |
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.
Ensure that contentStr contains '(' before calling substring to avoid potential index errors if the character is missing.
const lhs = contentStr.substring(0, contentStr.indexOf('(')) | |
const openParenIndex = contentStr.indexOf('('); | |
if (openParenIndex === -1) { | |
throw new Error("Expected '(' in contentStr but not found."); | |
} | |
const lhs = contentStr.substring(0, openParenIndex); |
Copilot uses AI. Check for mistakes.
}) | ||
.join('') | ||
const lhs = contentStr.substring(0, contentStr.indexOf('(')) | ||
let isLiteral = false |
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.
[nitpick] Consider adding a comment to explain the purpose of this loop and why only the first non-space character after '(' is checked.
let isLiteral = false | |
let isLiteral = false | |
// Check the first non-space character after '(' to determine if it is a literal object or array. | |
// This is used to decide how to rewrite the parameters for the function call. |
Copilot uses AI. Check for mistakes.
fixed: #4633