修复@taro/extend 4.1.1 版本,在微信小程序下,window is undefined 的问题
fix: window is undefind bug.
这个 PR 做了什么? (简要描述所做更改)
修复在小程序下使用 @taro/extend的时候 window 不存在的情况
TypeError: Cannot use 'in' operator to search for 'onfocusin' in undefined
这个 PR 是什么类型? (至少选择一个)
- [x] 错误修复 (Bugfix) issue: fix # https://github.com/NervJS/taro/issues/17837
- [ ] 新功能 (Feature)
- [ ] 代码重构 (Refactor)
- [ ] TypeScript 类型定义修改 (Types)
- [ ] 文档修改 (Docs)
- [ ] 代码风格更新 (Code style update)
- [ ] 构建优化 (Chore)
- [ ] 其他,请描述 (Other, please describe):
这个 PR 涉及以下平台:
- [ ] 所有小程序
- [x] 微信小程序
- [ ] 支付宝小程序
- [ ] 百度小程序
- [ ] 字节跳动小程序
- [ ] QQ 轻应用
- [ ] 京东小程序
- [ ] 快应用平台(QuickApp)
- [ ] Web 平台(H5)
- [ ] 移动端(React-Native)
- [ ] 鸿蒙(harmony)
Summary by CodeRabbit
- 杂项
- 优化了对 window 对象的引用方式,以提升在 Taro 运行环境中的兼容性。用户无需进行任何操作,功能保持不变。
"""
Walkthrough
本次变更在 packages/taro-extend/src/jquery/event.js 文件顶部新增了从 @tarojs/runtime 显式导入 window 的语句,用于替代对全局 window 的隐式引用。其他代码逻辑和功能未做任何修改。
Changes
| 文件/文件组 | 变更摘要 |
|---|---|
| packages/taro-extend/src/jquery/event.js | 新增从 @tarojs/runtime 导入 window,替换隐式全局引用 |
Possibly related issues
- NervJS/taro#17837:该问题描述了因隐式使用未定义的
window导致的 TypeError,本次变更通过显式导入window解决了此类错误,相关性强。
Poem
兔子轻跳键盘旁,
window 不再全局藏。
明确导入新气象,
代码清晰更安详。
🐇✨ """
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 0fac9e1788d155c19d2039d69d96314e27310882 and f47162733aa88a49583e27ecfab0b93c6d408839.
📒 Files selected for processing (1)
packages/taro-extend/src/jquery/event.js(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/taro-extend/src/jquery/event.js
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate Unit Tests
- [ ] Create PR with Unit Tests
- [ ] Post Copyable Unit Tests in Comment
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.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need 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)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai auto-generate unit teststo generate unit tests for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 55.90%. Comparing base (
209f84f) to head (f471627). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #17838 +/- ##
========================================
Coverage 55.90% 55.90%
========================================
Files 417 417
Lines 21693 21693
Branches 5364 5354 -10
========================================
Hits 12127 12127
- Misses 7964 8090 +126
+ Partials 1602 1476 -126
| Flag | Coverage Δ | |
|---|---|---|
| taro-cli | 72.42% <ø> (ø) |
|
| taro-runtime | 59.87% <ø> (ø) |
|
| taro-web | 53.19% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.