check:selection-kinds requires a handler only for the export items this plugin can show
The legend's card-deck item is opt-in: it sits behind v-if="exportCards", a prop that defaults to false. countries-map passes it and handles 'cards'; upg-100-list passes nothing, so its legend never shows the item and cannot emit it. The gate still demanded a 'cards' branch in upg-100-list's handler and failed gates:pre on a menu item that plugin never renders. An item guarded by a prop now needs a handler only where upg-100-list passes that prop. Both sides planted: upg-100-list opting in without a branch fails, and the legend losing the guard fails.
This commit is contained in:
parent
50b9f9a8a2
commit
63fb7fc834
1 changed files with 11 additions and 2 deletions
|
|
@ -131,8 +131,17 @@ for (const fn of ['onLegendExport', 'makeSelectionPacket', 'makeSelectionPoster'
|
|||
'onLegendExport no longer splits the kind — a packet:<variant> emit would fall through as an unknown kind and print nothing')
|
||||
for (const kind of emitted) {
|
||||
const [base] = kind.split(':')
|
||||
ok(base === 'poster' || base === 'packet',
|
||||
`the legend emits '${kind}', whose base '${base}' is neither poster nor packet — the plugin's handler has no branch for it`)
|
||||
if (base === 'poster' || base === 'packet') continue
|
||||
// ★ AN OPT-IN ITEM IS ONLY THIS PLUGIN'S PROBLEM IF THIS PLUGIN OPTS IN. The card deck ('cards') sits
|
||||
// behind v-if="exportCards", a prop that defaults to false: countries-map passes it and handles it,
|
||||
// and a legend here that never shows the item cannot emit it. So an item guarded by a prop is
|
||||
// required to have a handler branch only when upg-100-list.vue passes that prop.
|
||||
const line = LEGEND.split('\n').find((l) => l.includes(`emitExport('${kind}')`)) || ''
|
||||
const guard = (line.match(/v-if="(\w+)"/) || [])[1]
|
||||
const kebab = guard && guard.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase())
|
||||
const optedIn = !!guard && new RegExp(`[\\s:](?:${kebab}|${guard})\\b`).test(VUE)
|
||||
ok(guard && !optedIn,
|
||||
`the legend emits '${kind}', whose base '${base}' is neither poster nor packet — ${optedIn ? `upg-100-list passes ${guard}, but ` : ''}the plugin's handler has no branch for it`)
|
||||
}
|
||||
// The variant must actually travel to the renderer. Asserting the split alone would pass while
|
||||
// the parsed value was dropped on the floor.
|
||||
|
|
|
|||
Loading…
Reference in a new issue