parseWithSlots(source, { onError })
const index = source.indexOf('v-foo')
expect(onError.mock.calls[0][0]).toMatchObject({
- code: ErrorCodes.X_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
+ code: ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
loc: {
source: `v-foo`,
start: {
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
- code: ErrorCodes.X_FOR_NO_EXPRESSION
+ code: ErrorCodes.X_V_FOR_NO_EXPRESSION
})
)
})
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
- code: ErrorCodes.X_FOR_MALFORMED_EXPRESSION
+ code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
})
)
})
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
- code: ErrorCodes.X_FOR_MALFORMED_EXPRESSION
+ code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
})
)
})
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
- code: ErrorCodes.X_FOR_MALFORMED_EXPRESSION
+ code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
})
)
})
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
- code: ErrorCodes.X_FOR_MALFORMED_EXPRESSION
+ code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
})
)
})
const { node: node1 } = parseWithIfTransform(`<div v-else/>`, { onError })
expect(onError.mock.calls[0]).toMatchObject([
{
- code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
+ code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node1.loc
}
])
)
expect(onError.mock.calls[1]).toMatchObject([
{
- code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
+ code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node2.loc
}
])
)
expect(onError.mock.calls[2]).toMatchObject([
{
- code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
+ code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node3.loc
}
])
})
expect(onError.mock.calls[0]).toMatchObject([
{
- code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
+ code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node1.loc
}
])
)
expect(onError.mock.calls[1]).toMatchObject([
{
- code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
+ code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node2.loc
}
])
)
expect(onError.mock.calls[2]).toMatchObject([
{
- code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
+ code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node3.loc
}
])
parseWithSlots(source, { onError })
const index = source.indexOf('bar')
expect(onError.mock.calls[0][0]).toMatchObject({
- code: ErrorCodes.X_EXTRANEOUS_NON_SLOT_CHILDREN,
+ code: ErrorCodes.X_V_SLOT_EXTRANEOUS_NON_SLOT_CHILDREN,
loc: {
source: `bar`,
start: {
parseWithSlots(source, { onError })
const index = source.lastIndexOf('#foo')
expect(onError.mock.calls[0][0]).toMatchObject({
- code: ErrorCodes.X_DUPLICATE_SLOT_NAMES,
+ code: ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES,
loc: {
source: `#foo`,
start: {
parseWithSlots(source, { onError })
const index = source.lastIndexOf('#foo')
expect(onError.mock.calls[0][0]).toMatchObject({
- code: ErrorCodes.X_MIXED_SLOT_USAGE,
+ code: ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE,
loc: {
source: `#foo`,
start: {
parseWithSlots(source, { onError })
const index = source.indexOf('v-slot')
expect(onError.mock.calls[0][0]).toMatchObject({
- code: ErrorCodes.X_MISPLACED_V_SLOT,
+ code: ErrorCodes.X_V_SLOT_MISPLACED,
loc: {
source: `v-slot`,
start: {
parseWithSlots(source, { onError })
const index = source.indexOf('v-slot')
expect(onError.mock.calls[0][0]).toMatchObject({
- code: ErrorCodes.X_NAMED_SLOT_ON_COMPONENT,
+ code: ErrorCodes.X_V_SLOT_NAMED_SLOT_ON_COMPONENT,
loc: {
source: `v-slot:foo`,
start: {
X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END,
// transform errors
- X_IF_NO_EXPRESSION,
- X_ELSE_NO_ADJACENT_IF,
- X_FOR_NO_EXPRESSION,
- X_FOR_MALFORMED_EXPRESSION,
+ X_V_IF_NO_EXPRESSION,
+ X_V_ELSE_NO_ADJACENT_IF,
+ X_V_FOR_NO_EXPRESSION,
+ X_V_FOR_MALFORMED_EXPRESSION,
X_V_BIND_NO_EXPRESSION,
X_V_ON_NO_EXPRESSION,
X_V_HTML_NO_EXPRESSION,
X_V_HTML_WITH_CHILDREN,
- X_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
- X_NAMED_SLOT_ON_COMPONENT,
- X_MIXED_SLOT_USAGE,
- X_DUPLICATE_SLOT_NAMES,
- X_EXTRANEOUS_NON_SLOT_CHILDREN,
- X_MISPLACED_V_SLOT,
+ X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
+ X_V_SLOT_NAMED_SLOT_ON_COMPONENT,
+ X_V_SLOT_MIXED_SLOT_USAGE,
+ X_V_SLOT_DUPLICATE_SLOT_NAMES,
+ X_V_SLOT_EXTRANEOUS_NON_SLOT_CHILDREN,
+ X_V_SLOT_MISPLACED,
// generic errors
X_PREFIX_ID_NOT_SUPPORTED,
'Note that dynamic directive argument cannot contain spaces.',
// transform errors
- [ErrorCodes.X_IF_NO_EXPRESSION]: `v-if/v-else-if is missing expression.`,
- [ErrorCodes.X_ELSE_NO_ADJACENT_IF]: `v-else/v-else-if has no adjacent v-if.`,
- [ErrorCodes.X_FOR_NO_EXPRESSION]: `v-for is missing expression.`,
- [ErrorCodes.X_FOR_MALFORMED_EXPRESSION]: `v-for has invalid expression.`,
+ [ErrorCodes.X_V_IF_NO_EXPRESSION]: `v-if/v-else-if is missing expression.`,
+ [ErrorCodes.X_V_ELSE_NO_ADJACENT_IF]: `v-else/v-else-if has no adjacent v-if.`,
+ [ErrorCodes.X_V_FOR_NO_EXPRESSION]: `v-for is missing expression.`,
+ [ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION]: `v-for has invalid expression.`,
[ErrorCodes.X_V_BIND_NO_EXPRESSION]: `v-bind is missing expression.`,
[ErrorCodes.X_V_ON_NO_EXPRESSION]: `v-on is missing expression.`,
[ErrorCodes.X_V_HTML_NO_EXPRESSION]: `v-html is missing epxression.`,
[ErrorCodes.X_V_HTML_WITH_CHILDREN]: `v-html will override element children.`,
- [ErrorCodes.X_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET]: `Unexpected custom directive on <slot> outlet.`,
- [ErrorCodes.X_NAMED_SLOT_ON_COMPONENT]:
+ [ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET]: `Unexpected custom directive on <slot> outlet.`,
+ [ErrorCodes.X_V_SLOT_NAMED_SLOT_ON_COMPONENT]:
`Named v-slot on component. ` +
`Named slots should use <template v-slot> syntax nested inside the component.`,
- [ErrorCodes.X_MIXED_SLOT_USAGE]:
+ [ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE]:
`Mixed v-slot usage on both the component and nested <template>.` +
`The default slot should also use <template> syntax when there are other ` +
`named slots to avoid scope ambiguity.`,
- [ErrorCodes.X_DUPLICATE_SLOT_NAMES]: `Duplicate slot names found. `,
- [ErrorCodes.X_EXTRANEOUS_NON_SLOT_CHILDREN]:
+ [ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES]: `Duplicate slot names found. `,
+ [ErrorCodes.X_V_SLOT_EXTRANEOUS_NON_SLOT_CHILDREN]:
`Extraneous children found when component has explicit slots. ` +
`These children will be ignored.`,
- [ErrorCodes.X_MISPLACED_V_SLOT]: `v-slot can only be used on components or <template> tags.`,
+ [ErrorCodes.X_V_SLOT_MISPLACED]: `v-slot can only be used on components or <template> tags.`,
// generic errors
[ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
if (name === 'slot') {
if (!isComponent) {
context.onError(
- createCompilerError(ErrorCodes.X_MISPLACED_V_SLOT, loc)
+ createCompilerError(ErrorCodes.X_V_SLOT_MISPLACED, loc)
)
}
continue
if (directives.length) {
context.onError(
createCompilerError(
- ErrorCodes.X_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
+ ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
directives[0].loc
)
)
}
} else {
context.onError(
- createCompilerError(ErrorCodes.X_FOR_MALFORMED_EXPRESSION, dir.loc)
+ createCompilerError(ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION, dir.loc)
)
}
} else {
context.onError(
- createCompilerError(ErrorCodes.X_FOR_NO_EXPRESSION, dir.loc)
+ createCompilerError(ErrorCodes.X_V_FOR_NO_EXPRESSION, dir.loc)
)
}
}
) {
const loc = dir.exp ? dir.exp.loc : node.loc
context.onError(
- createCompilerError(ErrorCodes.X_IF_NO_EXPRESSION, dir.loc)
+ createCompilerError(ErrorCodes.X_V_IF_NO_EXPRESSION, dir.loc)
)
dir.exp = createSimpleExpression(`true`, false, loc)
}
}
} else {
context.onError(
- createCompilerError(ErrorCodes.X_ELSE_NO_ADJACENT_IF, node.loc)
+ createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, node.loc)
)
}
break
const { arg, exp, loc } = explicitDefaultSlot
if (arg) {
context.onError(
- createCompilerError(ErrorCodes.X_NAMED_SLOT_ON_COMPONENT, loc)
+ createCompilerError(ErrorCodes.X_V_SLOT_NAMED_SLOT_ON_COMPONENT, loc)
)
}
slotsProperties.push(buildDefaultSlot(exp, children, loc))
if (explicitDefaultSlot) {
// already has on-component default slot - this is incorrect usage.
context.onError(
- createCompilerError(ErrorCodes.X_MIXED_SLOT_USAGE, slotDir.loc)
+ createCompilerError(ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE, slotDir.loc)
)
break
}
: buildDynamicSlot(slotName, slotFunction)
} else {
context.onError(
- createCompilerError(ErrorCodes.X_ELSE_NO_ADJACENT_IF, vElse.loc)
+ createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, vElse.loc)
)
}
} else if ((vFor = findDir(slotElement, 'for'))) {
)
} else {
context.onError(
- createCompilerError(ErrorCodes.X_FOR_MALFORMED_EXPRESSION, vFor.loc)
+ createCompilerError(ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION, vFor.loc)
)
}
} else {
if (staticSlotName) {
if (seenSlotNames.has(staticSlotName)) {
context.onError(
- createCompilerError(ErrorCodes.X_DUPLICATE_SLOT_NAMES, dirLoc)
+ createCompilerError(
+ ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES,
+ dirLoc
+ )
)
continue
}
if (hasTemplateSlots && extraneousChild) {
context.onError(
createCompilerError(
- ErrorCodes.X_EXTRANEOUS_NON_SLOT_CHILDREN,
+ ErrorCodes.X_V_SLOT_EXTRANEOUS_NON_SLOT_CHILDREN,
extraneousChild.loc
)
)