Skip to content

Commit

Permalink
add reset in promise
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoloza committed Feb 5, 2025
1 parent 76cdf93 commit 9f896fe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/element/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { registry } from './mixins/index.js'
import { removeContent } from './mixins/content.js'
import { triggerEventOn, triggerEventOnUpdate } from '@domql/event'

export const resetElement = (params, element, options) => {
export const resetElement = async (params, element, options) => {
if (!options.preventRemove) removeContent(element, options)
const { __ref: ref } = element
create(params, element, ref.contentElementKey || 'content', {
await create(params, element, ref.contentElementKey || 'content', {
ignoreChildExtend: true,
...registry.defaultOptions,
...OPTIONS.create,
Expand Down Expand Up @@ -63,14 +63,14 @@ export const set = async function (params, options = {}, el) {
}

if (lazyLoad) {
window.requestAnimationFrame(() => {
resetElement(params, element, options)
window.requestAnimationFrame(async () => {
await resetElement(params, element, options)
// handle lazy load
if (!options.preventUpdateListener) {
triggerEventOn('lazyLoad', element, options)
}
})
} else resetElement(params, element, options)
} else await resetElement(params, element, options)
}

return element
Expand Down

0 comments on commit 9f896fe

Please sign in to comment.