{"record":{"id":"c2d14c12bc486430","repo":"slidevjs/slidev","slug":"invalid-range-for-v-switch-range","errorCode":null,"errorMessage":"Invalid range for v-switch: ${range}","messagePattern":"Invalid range for v-switch: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/builtin/VSwitch.ts","lineNumber":50,"sourceCode":"      type: String,\n      default: 'div',\n    },\n  },\n  setup({ at, unmount, transition, tag, childTag }, { slots }) {\n    const slotEntries = Object.entries(slots).sort((a, b) => -a[0].split('-')[0] + +b[0].split('-')[0])\n    const contents: [start: number, end: number, slot: Slot<any> | undefined, elRef: Ref<HTMLElement | undefined>][] = []\n\n    let lastStart: number | undefined\n    for (const [range, slot] of slotEntries) {\n      const elRef = ref<HTMLElement>()\n      if (Number.isFinite(+range)) {\n        contents.push([+range, lastStart ?? +range + 1, slot, elRef])\n        lastStart = +range\n      }\n      else {\n        const [start, end] = range.split('-').map(Number)\n        if (!Number.isFinite(start) || !Number.isFinite(end))\n          throw new Error(`Invalid range for v-switch: ${range}`)\n        contents.push([start, end, slot, elRef])\n        lastStart = start\n      }\n    }\n\n    const size = Math.max(...contents.map(c => c[1])) - 1\n    const id = makeId()\n    const offset = ref(0)\n\n    const { $clicksContext: clicks, $nav: nav } = useSlideContext()\n\n    onMounted(() => {\n      const clicksInfo = clicks.calculateSince(at, size)\n      if (!clicksInfo) {\n        offset.value = CLICKS_MAX\n        return\n      }\n      clicks.register(id, clicksInfo)","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/client/builtin/VSwitch.ts#L32-L68","documentation":"Thrown by the VSwitch component while parsing its named slot names. Each slot name must be either a single integer (e.g. '1') or a 'start-end' range (e.g. '2-4'); any other string that cannot be split into two finite numbers triggers this. The check happens in the component setup before any rendering logic runs.","triggerScenarios":"Defining a <v-switch> with a malformed slot name such as #1..3, #1:3, #1~3, #abc, #1- (trailing dash), or any name containing characters other than digits and a single dash.","commonSituations":"Copying range syntax from another tool (Python slices use ':', CSS uses '/'), typos in slot names, or stray whitespace/punctuation introduced by editor auto-formatting.","solutions":["Rename the slot to a single integer (#1) or a dash-separated range (#1-3)","Remove any non-digit characters from the slot name","If you intended a single-step switch, use a plain integer slot name"],"exampleFix":"// before\n<template #1..3>...</template>\n// after\n<template #1-3>...</template>","handlingStrategy":"validation","validationCode":"function isValidSwitchSlot(name: string): boolean {\n  return /^\\d+$/.test(name) || /^\\d+-\\d+$/.test(name)\n}\n// before rendering <v-switch>:\nObject.keys($slots).forEach(n => { if (!isValidSwitchSlot(n)) throw new Error(`Bad v-switch slot: ${n}`) })","typeGuard":"function isSwitchSlotName(name: string): name is `${number}` | `${number}-${number}` {\n  return /^\\d+$/.test(name) || /^\\d+-\\d+$/.test(name)\n}","tryCatchPattern":null,"preventionTips":["Only use plain integers or dash-separated integer ranges as v-switch slot names","Add a lint rule or unit test asserting slot names match /^\\d+(-\\d+)?$/"],"tags":["vue","v-switch","slot","parsing"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}