Skip to content

Commit 033d62f

Browse files
committed
fix(compiler): remove compiler error for v-slots
1 parent 3c22e74 commit 033d62f

File tree

3 files changed

+5
-38
lines changed

3 files changed

+5
-38
lines changed
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { createCompilerError, ErrorCodes } from '@vue/compiler-dom'
21
import { IRSlotType } from '../ir'
3-
import { isJSXComponent, resolveExpression, resolveLocation } from '../utils'
2+
import { isJSXComponent, resolveExpression } from '../utils'
43
import type { DirectiveTransform } from '../transform'
54

65
export const transformVSlots: DirectiveTransform = (dir, node, context) => {
@@ -13,14 +12,5 @@ export const transformVSlots: DirectiveTransform = (dir, node, context) => {
1312
slots: resolveExpression(dir.value.expression, context),
1413
},
1514
]
16-
17-
if (node.children.length) {
18-
context.options.onError(
19-
createCompilerError(
20-
ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE,
21-
resolveLocation(node.children[0].loc, context),
22-
),
23-
)
24-
}
2515
}
2616
}

packages/compiler/test/transforms/__snapshots__/vSlots.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
exports[`compiler: transform v-slots > basic 1`] = `
44
"
5-
const n0 = _createComponent(Comp, null, {
5+
const n1 = _createComponent(Comp, null, {
66
$: [
77
{ default: ({ foo })=> <>{ foo + bar }</> }
88
]
99
}, true)
10-
return n0
10+
return n1
1111
"
1212
`;
Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { ErrorCodes } from '@vue/compiler-dom'
2-
import { describe, expect, test, vi } from 'vitest'
1+
import { describe, expect, test } from 'vitest'
32
import {
43
transformChildren,
54
transformElement,
@@ -28,30 +27,8 @@ const compileWithSlots = makeCompile({
2827
describe('compiler: transform v-slots', () => {
2928
test('basic', () => {
3029
const { code } = compileWithSlots(
31-
`<Comp v-slots={{ default: ({ foo })=> <>{ foo + bar }</> }}></Comp>`,
30+
`<Comp v-slots={{ default: ({ foo })=> <>{ foo + bar }</> }}> </Comp>`,
3231
)
3332
expect(code).toMatchSnapshot()
3433
})
35-
36-
test('error on invalid mixed slot usage', () => {
37-
const onError = vi.fn()
38-
const source = `<Comp v-slots={{ default: ({ foo })=> <>{ foo + bar }</> }}>foo</Comp>`
39-
compileWithSlots(source, { onError })
40-
const index = source.lastIndexOf('foo')
41-
expect(onError.mock.calls[0][0]).toMatchObject({
42-
code: ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE,
43-
loc: {
44-
start: {
45-
offset: index,
46-
line: 1,
47-
column: index + 1,
48-
},
49-
end: {
50-
offset: index + 3,
51-
line: 1,
52-
column: index + 4,
53-
},
54-
},
55-
})
56-
})
5734
})

0 commit comments

Comments
 (0)