Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 855e5f4

Browse files
committed
refactor: remove ref for el
1 parent a9a9e85 commit 855e5f4

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

packages/runtime-vapor/src/directives.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from './component'
77
import { warn } from './warning'
88
import { normalizeBlock } from './dom/element'
9-
import { type ShallowRef, getCurrentScope, shallowRef } from '@vue/reactivity'
9+
import { getCurrentScope } from '@vue/reactivity'
1010
import { VaporErrorCodes, callWithAsyncErrorHandling } from './errorHandling'
1111

1212
export type DirectiveModifiers<M extends string = string> = Record<M, boolean>
@@ -22,7 +22,7 @@ export interface DirectiveBinding<T = any, V = any, M extends string = string> {
2222
export type DirectiveBindingsMap = Map<Node, DirectiveBinding[]>
2323

2424
export type Directive<T = any, V = any, M extends string = string> = (
25-
node: ShallowRef<T>,
25+
node: T,
2626
binding: DirectiveBinding<T, V, M>,
2727
) => void
2828

@@ -82,7 +82,7 @@ export function withDirectives<T extends ComponentInternalInstance | Node>(
8282
}
8383

8484
callWithAsyncErrorHandling(dir, instance, VaporErrorCodes.DIRECTIVE_HOOK, [
85-
shallowRef(node),
85+
node,
8686
binding,
8787
])
8888
}

packages/runtime-vapor/src/directives/vModel.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const vModelText: Directive<
4747
HTMLInputElement | HTMLTextAreaElement,
4848
any,
4949
'lazy' | 'trim' | 'number'
50-
> = ({ value: el }, { source, modifiers: { lazy, trim, number } = {} }) => {
50+
> = (el, { source, modifiers: { lazy, trim, number } = {} }) => {
5151
onBeforeMount(() => {
5252
const assigner = getModelAssigner(el)
5353
assignFnMap.set(el, assigner)
@@ -116,10 +116,7 @@ export const vModelText: Directive<
116116
})
117117
}
118118

119-
export const vModelRadio: Directive<HTMLInputElement> = (
120-
{ value: el },
121-
{ source },
122-
) => {
119+
export const vModelRadio: Directive<HTMLInputElement> = (el, { source }) => {
123120
onBeforeMount(() => {
124121
el.checked = looseEqual(source(), getValue(el))
125122
assignFnMap.set(el, getModelAssigner(el))
@@ -136,7 +133,7 @@ export const vModelRadio: Directive<HTMLInputElement> = (
136133
}
137134

138135
export const vModelSelect: Directive<HTMLSelectElement, any, 'number'> = (
139-
{ value: el },
136+
el,
140137
{ source, modifiers: { number = false } = {} },
141138
) => {
142139
onBeforeMount(() => {
@@ -235,10 +232,7 @@ function getCheckboxValue(el: HTMLInputElement, checked: boolean) {
235232
return checked
236233
}
237234

238-
export const vModelCheckbox: Directive<HTMLInputElement> = (
239-
{ value: el },
240-
{ source },
241-
) => {
235+
export const vModelCheckbox: Directive<HTMLInputElement> = (el, { source }) => {
242236
onBeforeMount(() => {
243237
assignFnMap.set(el, getModelAssigner(el))
244238

@@ -294,10 +288,10 @@ export const vModelCheckbox: Directive<HTMLInputElement> = (
294288

295289
export const vModelDynamic: Directive<
296290
HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
297-
> = (elRef, binding) => {
298-
const type = elRef.value.getAttribute('type')
299-
const modelToUse = resolveDynamicModel(elRef.value.tagName, type)
300-
modelToUse(elRef, binding)
291+
> = (el, binding) => {
292+
const type = el.getAttribute('type')
293+
const modelToUse = resolveDynamicModel(el.tagName, type)
294+
modelToUse(el, binding)
301295
}
302296

303297
function resolveDynamicModel(tagName: string, type: string | null): Directive {

packages/runtime-vapor/src/directives/vShow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface VShowElement extends HTMLElement {
1010
[vShowHidden]: boolean
1111
}
1212

13-
export const vShow: Directive<VShowElement> = ({ value: el }, { source }) => {
13+
export const vShow: Directive<VShowElement> = (el, { source }) => {
1414
el[vShowOriginalDisplay] = el.style.display === 'none' ? '' : el.style.display
1515
renderEffect(() => setDisplay(el, source()))
1616
}

0 commit comments

Comments
 (0)