Skip to content

Commit

Permalink
fix(runtime-web): 修复 swiper 组件空指针异常 (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
shujian-cao committed Aug 17, 2023
1 parent fb4d18b commit d1046a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/alipay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"repository": "[email protected]:eleme/morjs.git",
"scripts": {
"dev": "mor compile -w",
"dev:ali": "mor compile --name ali -w",
"dev:web": "mor compile --name web -w",
"build": "mor compile"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ export default class TigaSwiper extends LitElement {
this.swiperWrapper = this.querySelector(
`.tiga-swiper-${this.swiperId} > .swiper-container > .swiper-wrapper`
) as any

;(this as any).appendChild = (newChild: HTMLElement) => {
if (!this.isElementNode(newChild)) return

Expand Down Expand Up @@ -361,7 +360,7 @@ export default class TigaSwiper extends LitElement {

watchAutoPlay() {
if (
!this.swiper.autoplay ||
!this.swiper?.autoplay ||
this.swiper.autoplay.running === this[properties.AUTOPLAY]
)
return
Expand All @@ -378,7 +377,7 @@ export default class TigaSwiper extends LitElement {
}

watchCurrent() {
if (isNaN(this[properties.CURRENT])) return
if (!this.swiper || isNaN(this[properties.CURRENT])) return

if (this[properties.CIRCULAR]) {
if (!this.swiper.isBeginning && !this.swiper.isEnd) {
Expand All @@ -390,10 +389,14 @@ export default class TigaSwiper extends LitElement {
}

watchDuration() {
if (!this.swiper) return

this.swiper.params.speed = this[properties.DURATION]
}

watchInterval() {
if (!this.swiper) return

this.swiper.params.autoplay.delay = this[properties.INTERVAL]
}

Expand Down

0 comments on commit d1046a6

Please sign in to comment.