Skip to content

Commit 628b2b8

Browse files
committed
wip: update
1 parent 8543baa commit 628b2b8

File tree

6 files changed

+20
-1
lines changed

6 files changed

+20
-1
lines changed

packages/compiler-dom/__tests__/transforms/vModel.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { transformElement } from '../../../compiler-core/src/transforms/transfor
1010
import { DOMErrorCodes } from '../../src/errors'
1111
import {
1212
V_MODEL_CHECKBOX,
13+
V_MODEL_DETAILS,
1314
V_MODEL_DYNAMIC,
1415
V_MODEL_RADIO,
1516
V_MODEL_SELECT,
@@ -99,6 +100,12 @@ describe('compiler: transform v-model', () => {
99100
expect(generate(root).code).toMatchSnapshot()
100101
})
101102

103+
test('simple expression for details', () => {
104+
const root = transformWithModel('<details v-model="model" />')
105+
expect(root.helpers).toContain(V_MODEL_DETAILS)
106+
expect(generate(root).code).toMatchSnapshot()
107+
})
108+
102109
describe('errors', () => {
103110
test('plain elements with argument', () => {
104111
const onError = vi.fn()

packages/compiler-dom/src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const DOMErrorMessages: Record<DOMErrorCodes, string> = {
5353
[DOMErrorCodes.X_V_HTML_WITH_CHILDREN]: `v-html will override element children.`,
5454
[DOMErrorCodes.X_V_TEXT_NO_EXPRESSION]: `v-text is missing expression.`,
5555
[DOMErrorCodes.X_V_TEXT_WITH_CHILDREN]: `v-text will override element children.`,
56-
[DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
56+
[DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT]: `v-model can only be used on <input>, <textarea>, <select> and <details> elements.`,
5757
[DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT]: `v-model argument is not supported on plain elements.`,
5858
[DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
5959
[DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,

packages/compiler-dom/src/runtimeHelpers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export const V_MODEL_TEXT: unique symbol = Symbol(__DEV__ ? `vModelText` : ``)
88
export const V_MODEL_SELECT: unique symbol = Symbol(
99
__DEV__ ? `vModelSelect` : ``,
1010
)
11+
export const V_MODEL_DETAILS: unique symbol = Symbol(
12+
__DEV__ ? `vModelDetails` : ``,
13+
)
1114
export const V_MODEL_DYNAMIC: unique symbol = Symbol(
1215
__DEV__ ? `vModelDynamic` : ``,
1316
)

packages/compiler-dom/src/transforms/vModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
5151
tag === 'input' ||
5252
tag === 'textarea' ||
5353
tag === 'select' ||
54+
tag === 'details' ||
5455
isCustomElement
5556
) {
5657
let directiveToUse = V_MODEL_TEXT

packages/compiler-ssr/src/transforms/ssrVModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
174174
node.children = [createInterpolation(model, model.loc)]
175175
} else if (node.tag === 'select') {
176176
processSelectChildren(node.children)
177+
} else if (node.tag === 'details') {
178+
// TODO
177179
} else {
178180
context.onError(
179181
createDOMCompilerError(

packages/compiler-vapor/__tests__/transforms/vModel.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ describe('compiler: vModel transform', () => {
7777
expect(root2.helpers).toContain('applyDynamicModel')
7878
})
7979

80+
test.todo('should support details', () => {
81+
const { code, helpers } = compileWithVModel('<details v-model="model" />')
82+
expect(code).toMatchSnapshot()
83+
expect(helpers).toContain('applyDetailsModel')
84+
})
85+
8086
describe('errors', () => {
8187
test('invalid element', () => {
8288
const onError = vi.fn()

0 commit comments

Comments
 (0)