Skip to content

Commit a901b98

Browse files
committed
componentReady also returns promise now
1 parent fe5319c commit a901b98

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/components.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,14 @@ export const updateComponent = function (el, config, stage, afterProps) {
122122
return el
123123
}
124124

125-
export const componentReady = (el, fn) => run(() => {
125+
export const componentReady = (el, fn) => new Promise(resolve => run(() => {
126126
el = $(el)
127-
if (el.componentReady) return fn(el)
128-
el.once.componentReady(e => fn(el))
129-
})
127+
if (el.componentReady) {
128+
resolve(el)
129+
if (fn) return fn(el)
130+
}
131+
el.once.componentReady(e => {
132+
resolve(el)
133+
if (fn) fn(el)
134+
})
135+
}))

0 commit comments

Comments
 (0)