Skip to content

Fix array-style props corrupting data(), and props being dropped from compiled output - #9

Merged
aldanedev-create merged 1 commit into
mainfrom
fix/vel-runtime-and-css
Aug 26, 2026
Merged

Fix array-style props corrupting data(), and props being dropped from compiled output#9
aldanedev-create merged 1 commit into
mainfrom
fix/vel-runtime-and-css

Conversation

@aldanedev-create

Copy link
Copy Markdown
Owner

One commit that landed after PR #8 was already merged - see commit message for full details. Fixes two compounding bugs: array-form props (props: [...]) could silently corrupt an unrelated later property (usually data()), and props were never emitted into the compiled output at all regardless of form.

…ps being silently dropped entirely

Continued the @teloce/sfc audit, found two compounding bugs affecting
`props` declarations - both confirmed with real compile tests.

extractObjectProperty jumping to the wrong `{` entirely (packages/sfc/
src/script/index.ts):
- After finding a top-level key via findTopLevelKey, this searched for
  the property's value with `objStr.indexOf('{', keyIdx)` - the
  position of the *nearest* `{` anywhere after the key, with no check
  that the key's own value was actually an object literal in the first
  place. For an array-style props declaration (`props: ['label',
  'count']` - a real, documented, valid way to declare props with no
  object literal anywhere in it), that search skipped straight past the
  array and matched a completely unrelated *later* property's opening
  brace. Confirmed via an actual compile: `props: ['label', 'count'],
  data() { return {}; }` extracted data()'s own function body content
  and assigned it as if it were the props definition - silently
  corrupting one property's extracted value with a different property's
  content entirely, with zero error reported. Fixed by verifying the
  character immediately following `propName:` (skipping whitespace) is
  actually `{` before searching for it at all; otherwise this correctly
  returns null so the array-form fallback (already present, from an
  earlier commit's fix) gets a chance to run instead.

props silently dropped from the final compiled output regardless
(packages/sfc/src/compile.ts):
- Independent of the above, generateCode() never emitted `props` into
  the compiled defineComponent({...}) call at all - only data/methods/
  computed/lifecycle. A component author writing `props: [...]` or the
  object form had it correctly extracted by compileScript but then
  discarded outright, so the compiled component definition never
  carried a props field regardless of what was written. (This didn't
  break the component-composition prop-passing added in an earlier
  commit, since that overlays whatever a parent passes directly into
  the child's reactive state without consulting the child's own
  declared props list at all - but it meant `props: [...]` as written
  by a component author was silently dead syntax with zero effect,
  which is exactly the kind of "wrote something reasonable, nothing
  happened, no error" gap this whole audit has been finding.) Fixed by
  adding `props: ${exports.props}` to the generated output alongside
  the other fields.

Verified: array-form and object-form props now both correctly appear in
compiled output, with data()/methods no longer corrupted by the fix (
re-verified the earlier nested-methods-collision fix from a previous
commit still holds); full regression sweep across everything from this
session and previous ones still passes; full "pnpm -r build" across the
whole workspace with zero errors.
@aldanedev-create
aldanedev-create merged commit 7e7af37 into main Aug 26, 2026
1 check passed
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