-
Notifications
You must be signed in to change notification settings - Fork 299
fix(swipe): guard document.addEventListener in Taro env #3514
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
Changes from all commits
39584b9
12a451d
ccd5b75
a6d7fde
eaaa67c
9f49311
3d0f573
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| exports[`content test 1`] = ` | ||
| <div> | ||
| <div | ||
| arialabel="蒙层" | ||
| class="nut-overlay" | ||
| style="z-index: 1000;" | ||
| > | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ test('should change z-index when using z-index prop', () => { | |
| // @ts-ignore | ||
| expect(getByTestId('overlay-zindex')).toMatchInlineSnapshot(` | ||
| <div | ||
| arialabel="蒙层" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 不要在快照中固化错误的 ARIA 属性名。
建议的快照修改- arialabel="蒙层"
+ aria-label="蒙层"🤖 Prompt for AI Agents |
||
| class="nut-overlay" | ||
| data-testid="overlay-zindex" | ||
| style="z-index: 99;" | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`timeselect props test 1`] = `"<div><div class="nut-overlay" style="z-index: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-wrapper"><div class="nut-popup-title-title">取件时间</div></div><div class="nut-popup-title-right nut-popup-title-right-top-right"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="M512 557.23 783.57 828.8c8.32 8.32 21.76 8.32 30.3 0l14.93-14.93c8.32-8.32 8.32-21.76 0-30.3L557.23 512 828.8 240.43c8.32-8.32 8.32-21.76 0-30.3l-14.93-14.93c-8.32-8.32-21.76-8.32-30.3 0L512 466.77 240.43 195.2c-8.32-8.32-21.76-8.32-30.3 0l-14.93 14.93c-8.32 8.32-8.32 21.76 0 30.3L466.77 512 195.2 783.57c-8.32 8.32-8.32 21.76 0 30.3l14.93 14.93c8.32 8.32 21.76 8.32 30.3 0z" fill="currentColor"></path></svg></div></div><div class="nut-timeselect"><div class="nut-timeselect-content"><div class="nut-timeselect-content-left"><div class="nut-timepannel active">520</div><div class="nut-timepannel">521</div></div><div class="nut-timedetail"><span class="nut-timedetail-item">09:00-10:00</span><span class="nut-timedetail-item">10:00-11:00</span><span class="nut-timedetail-item">11:00-12:00</span></div></div></div></div></div>"`; | ||
| exports[`timeselect props test 1`] = `"<div><div class="nut-overlay" style="z-index: 1000;" arialabel="蒙层"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom" role="dialog"><div class="nut-popup-title"><div class="nut-popup-title-wrapper"><div class="nut-popup-title-title">取件时间</div></div><div class="nut-popup-title-right nut-popup-title-right-top-right" role="button" aria-label="关闭" tabindex="0"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="M512 557.23 783.57 828.8c8.32 8.32 21.76 8.32 30.3 0l14.93-14.93c8.32-8.32 8.32-21.76 0-30.3L557.23 512 828.8 240.43c8.32-8.32 8.32-21.76 0-30.3l-14.93-14.93c-8.32-8.32-21.76-8.32-30.3 0L512 466.77 240.43 195.2c-8.32-8.32-21.76-8.32-30.3 0l-14.93 14.93c-8.32 8.32-8.32 21.76 0 30.3L466.77 512 195.2 783.57c-8.32 8.32-8.32 21.76 0 30.3l14.93 14.93c8.32 8.32 21.76 8.32 30.3 0z" fill="currentColor"></path></svg></div></div><div class="nut-timeselect"><div class="nut-timeselect-content"><div class="nut-timeselect-content-left"><div class="nut-timepannel active">520</div><div class="nut-timepannel">521</div></div><div class="nut-timedetail"><span class="nut-timedetail-item">09:00-10:00</span><span class="nut-timedetail-item">10:00-11:00</span><span class="nut-timedetail-item">11:00-12:00</span></div></div></div></div></div>"`; |
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
让三组测试覆盖真实组件行为,而不是复制守卫表达式。
这些用例只验证本地
shouldSkip计算结果。它们不会在生产组件路径中触发 DOM API。因此删除任一生产守卫后,测试仍可能通过。src/packages/barrage/__tests__/barrage.spec.tsx#L98-L101: 触发 Barrage 的play,并验证createElement不可用时不抛错且不会调用createElement。src/packages/imagepreview/__test__/imagepreview.spec.tsx#L206-L209: 触发 ImagePreview 初始化,并验证不会注册addEventListener。src/packages/swipe/__tests__/swipe.spec.tsx#L108-L111: 挂载 Swipe,并验证不会注册addEventListener。📍 Affects 3 files
src/packages/barrage/__tests__/barrage.spec.tsx#L98-L101(this comment)src/packages/imagepreview/__test__/imagepreview.spec.tsx#L206-L209src/packages/swipe/__tests__/swipe.spec.tsx#L108-L111🤖 Prompt for AI Agents