Skip to content

Commit

Permalink
fix(ui/lazy): 修复install报错
Browse files Browse the repository at this point in the history
affects: @varlet/ui
  • Loading branch information
haoziqaq committed Apr 6, 2021
1 parent 78cce5f commit 187b822
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions packages/varlet-ui/src/lazy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ import {
} from '../utils/shared'

interface LazyOptions {
loading?: string
error?: string
attempt?: number
throttleWait?: number
filter?: (lazy: Lazy) => void
events?: string[]
loading?: string
error?: string
attempt?: number
throttleWait?: number
filter?: (lazy: Lazy) => void
events?: string[]
}

type LazyState = 'pending' | 'success' | 'error'

type Lazy = LazyOptions & {
src: string
arg: string | undefined
currentAttempt: number
attemptLock: boolean
state: LazyState
src: string
arg: string | undefined
currentAttempt: number
attemptLock: boolean
state: LazyState
}

export type LazyHTMLElement = HTMLElement & { _lazy: Lazy }
Expand Down Expand Up @@ -208,10 +208,10 @@ function diff(el: LazyHTMLElement, binding: DirectiveBinding<string>): boolean {

return (
src !== binding.value ||
arg !== binding.arg ||
attempt !== Number(el.getAttribute(LAZY_ATTEMPT)) ||
loading !== el.getAttribute(LAZY_LOADING) ||
error !== el.getAttribute(LAZY_ERROR)
arg !== binding.arg ||
attempt !== Number(el.getAttribute(LAZY_ATTEMPT)) ||
loading !== el.getAttribute(LAZY_LOADING) ||
error !== el.getAttribute(LAZY_ERROR)
)
}

Expand All @@ -231,7 +231,7 @@ function updated(el: LazyHTMLElement, binding: DirectiveBinding<string>) {
mounted(el, binding)
}

function mergeLazyOptions(lazyOptions: LazyOptions) {
function mergeLazyOptions(lazyOptions: LazyOptions = {}) {
const { events, loading, error, attempt, throttleWait, filter } = lazyOptions

defaultLazyOptions.events = events ?? defaultLazyOptions.events
Expand Down

0 comments on commit 187b822

Please sign in to comment.