Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c12427

Browse filesBrowse files
fix(useResizeObserver): fix target is Ref Array (#4005)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent fe19c74 commit 1c12427
Copy full SHA for 1c12427

File tree

Expand file treeCollapse file tree

1 file changed

+9
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-7
lines changed

‎packages/core/useResizeObserver/index.ts

Copy file name to clipboardExpand all lines: packages/core/useResizeObserver/index.ts
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { tryOnScopeDispose } from '@vueuse/shared'
1+
import { type MaybeRefOrGetter, toValue, tryOnScopeDispose } from '@vueuse/shared'
22
import { computed, watch } from 'vue-demi'
3-
import type { MaybeComputedElementRef } from '../unrefElement'
3+
import type { MaybeComputedElementRef, MaybeElement } from '../unrefElement'
44
import { unrefElement } from '../unrefElement'
55
import { useSupported } from '../useSupported'
66
import type { ConfigurableWindow } from '../_configurable'
@@ -47,7 +47,7 @@ declare class ResizeObserver {
4747
* @param options
4848
*/
4949
export function useResizeObserver(
50-
target: MaybeComputedElementRef | MaybeComputedElementRef[],
50+
target: MaybeComputedElementRef | MaybeComputedElementRef[] | MaybeRefOrGetter<MaybeElement[]>,
5151
callback: ResizeObserverCallback,
5252
options: UseResizeObserverOptions = {},
5353
) {
@@ -62,10 +62,12 @@ export function useResizeObserver(
6262
}
6363
}
6464

65-
const targets = computed(() =>
66-
Array.isArray(target)
67-
? target.map(el => unrefElement(el))
68-
: [unrefElement(target)])
65+
const targets = computed(() => {
66+
const _targets = toValue(target)
67+
return Array.isArray(_targets)
68+
? _targets.map(el => unrefElement(el))
69+
: [unrefElement(_targets)]
70+
})
6971

7072
const stopWatch = watch(
7173
targets,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.