Skip to content

fix: make SpellCard footnotes reactive via computed#38

Open
ArchiDevil wants to merge 1 commit into
mainfrom
fix/spellcard-reactive-footnotes
Open

fix: make SpellCard footnotes reactive via computed#38
ArchiDevil wants to merge 1 commit into
mainfrom
fix/spellcard-reactive-footnotes

Conversation

@ArchiDevil

Copy link
Copy Markdown
Owner

Problem

SpellCard had a shared mutable footnotes: string[] array that was mutated from two separate computed() properties (components and castTimes). Vue does not guarantee the order of computed evaluation, so footnote indices could swap unpredictably between renders.

The footnote index refs (materialComponentFootnote, castTimesFootnote) depended on footnotes.length at mutation time — non-deterministic.

Changes

Refactored to a pure computed chain — no side effects, no shared mutable state:

  • componentMatch — single regex exec, shared by derived computeds
  • materialComponent — extracts the material component string
  • components — no longer mutates anything, just parses
  • castTimeInfo — returns {label, footnote} in one pass (replaces castTimes + footnote mutation)
  • footnotes — built deterministically: material component first, then cast time
  • materialComponentFootnote / castTimesFootnote — derived from whether the corresponding footnote exists

Also removed footnotes.length = 0 from the watch — no longer needed since footnotes is computed.

Template is unchanged.

Remove shared mutable footnotes array that was mutated from two
separate computed() properties (components and castTimes). The order
of computed evaluation is not guaranteed by Vue, so footnote indices
could swap unpredictably.

Refactored to pure computed chain:
- materialComponent: extracts material component string
- componentMatch: single regex exec, shared by materialComponent and components
- castTimeInfo: returns {label, footnote} in one pass
- footnotes: built from materialComponent + castTimeInfo
- materialComponentFootnote / castTimesFootnote: derived indices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant