Skip to content

Commit

Permalink
fix(ripple): _ripple may be null in nuxt and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Feb 5, 2024
1 parent 6f72b75 commit 77c4ddc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/varlet-ui/src/back-top/BackTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default defineComponent({
function removeScrollerEventListener() {
if (!scroller) {
// may be null in nuxt
return
}
Expand Down
1 change: 1 addition & 0 deletions packages/varlet-ui/src/index-bar/IndexBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export default defineComponent({
function removeScrollerListener() {
if (!scroller) {
// may be null in nuxt
return
}
Expand Down
1 change: 1 addition & 0 deletions packages/varlet-ui/src/list/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default defineComponent({

function removeScrollerListener() {
if (!scroller) {
// may be null in nuxt
return
}

Expand Down
6 changes: 6 additions & 0 deletions packages/varlet-ui/src/ripple/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ function unmounted(el: RippleHTMLElement) {
el.removeEventListener('touchstart', createRipple)
el.removeEventListener('touchmove', forbidRippleTask)
el.removeEventListener('dragstart', removeRipple)

if (!el._ripple || !el._ripple.removeRipple) {
// may be null in nuxt
return
}

document.removeEventListener('touchend', el._ripple!.removeRipple)
document.removeEventListener('touchcancel', el._ripple!.removeRipple)
document.removeEventListener('dragend', el._ripple!.removeRipple)
Expand Down
1 change: 1 addition & 0 deletions packages/varlet-ui/src/sticky/Sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default defineComponent({
function removeScrollListener() {
if (!scroller || scroller === window) {
// may be null in nuxt
return
}
Expand Down

0 comments on commit 77c4ddc

Please sign in to comment.