Repository navigation
fix: raise VueCodeError for a Vue-code c-bind key on c-slot and c-fill - #625
Merged
Merged
Conversation
#559) A c-bind key that Vue would read as code, such as ":row" or "v-slot", on <c-slot> or <c-fill> raised a plain RuntimeError at render, while HTML elements and component tags raise VueCodeError for the same mistake. Both tags now raise VueCodeError, with the same messages. A $c-tr key in c-bind does too. Citry's own @c-* and :c-* names and unknown keys on <c-fill> keep raising RuntimeError, because they are not Vue code. The change is breaking for code that catches RuntimeError around these renders, so it has a changelog entry. The VueCodeError docstring and the slots, CSP and Vue design docs name the two tags. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ct text (#559) <c-slot> passed two names to the fill as slot data that every other tag refuses: a $c-tr binding written as a c- attribute (c-$c-tr:x) and a c-bind key that is just ".". It also decided on a c-bind key with the key's own startswith, so a str subclass could hide a Vue-code name. All three now raise VueCodeError. The refusal follows is_vue_code_attr_name, so a Vue-code key with no slot-specific message is still refused. A new exact_str() helper gives the checks the real text of a key. <c-slot>, <c-fill> and component tags use it, so a str subclass that overrides startswith or __eq__ gets the same result as a plain str. These are breaking changes for code that passes such names to <c-slot>, so the changelog says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
force-pushed
the
fix/vuecodeerror-slot-bind
branch
from
November 14, 2026 13:43
278d225 to
3d709f9
Compare
JuroOravec
marked this pull request as ready for review
November 14, 2026 13:44
This was referenced Nov 14, 2026
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of 0.9.0. 0.8.0 is released. This changes exception types and refuses names that used to pass, so it ships in a minor release. Its changelog entries are under Unreleased.
What this does
Closes #559.
1.
VueCodeErrorfor a Vue-codec-bindkey on<c-slot>and<c-fill>A
c-bindkey that Vue would read as code, such as":row"or"v-slot", on<c-slot>or<c-fill>was refused at render with a plainRuntimeError. HTML elements and component tags raiseVueCodeError(aTypeError) for the same mistake, and its docstring promises it for every such key. Code that catchesVueCodeErrormissed the slot and fill cases.Now
<c-slot>and<c-fill>raiseVueCodeErrortoo, with the same messages. The render failed before as well, so only the exception type changes.<c-slot c-bind>: a key thatis_vue_code_attr_nameaccepts (:row,v-slot,v-if,@click,#x,.x,^x, any letter case) raisesVueCodeError. The rule decides, not the message lookup: a Vue-code key that has no slot-specific message still raisesVueCodeError, with the general message.<c-fill c-bind>: the same keys raiseVueCodeErrorin the "unsupported key" check. An unknown plain key such as"bogus"staysRuntimeError.$c-trkey inc-bindon<c-slot>or<c-fill>raisesVueCodeError, as it already does on elements and component tags.2. Two more names that
<c-slot>used to pass as slot data are refused (breaking)Both raise
VueCodeErrornow. Neither reached the browser, because slot data stays on the server, but the tag did not refuse them as it refuses the other Vue-code names.<c-slot c-$c-tr:x="y" />: ac-attribute whose name is a$c-trbinding. The parser does not reject it, so the slot took$c-tr:xas a slot data key.SlotNodenow checks itsc-*attribute names once at construction, asComponentNodedoes, and raises with the component-tag message style plus advice that fits a slot.<c-slot>, ac-bindkey that is just".", or astrsubclass that overridesstartswithand so hides its text.unsupported_slot_tag_directive_messageskipped a bare., and it read the key through the subclass's own methods. It now treats every.-prefixed key as a DOM-property binding and reads the key as an exactstr.Sweep for siblings:
exact_str()inattrs.pyreturns the exactstrtext of a key.validate_html_attr_namealready did this inline for HTML elements and<c-element>; it now calls the helper.<c-fill>checkedis_vue_code_attr_name, which already reads real text, but compared the key within ("name", "data", "fallback"), which uses the subclass's__eq__. It now uses the exact key too, as<c-slot>does fornameandrequired.<c-element>) tested the:c-*State binding andx-on:*refusals with the subclass'sstartswith. Astrsubclass spelling:c-valueslipped past it as a kwarg. They now use the exact key, so it raises the sameRuntimeErroras a plainstr.c-bindcarrying:row,$c-tr:x,., and disguised keys, and with ac-$c-tr:xattribute.<c-slot>was the only tag that accepted any of them. The tags with a fixed attribute list rejectc-$c-tr:xat parse time like any unknown attribute.strmixin enum keys keep working as a component kwarg, a slot data key, and a fill name (covered by tests).Left as
RuntimeErroron purposeNot a name that Python data chose and that Vue reads as code, which is what
VueCodeErrorcovers:@c-*and:c-*names inc-bindon<c-slot>and<c-fill>. They are not Vue code (is_vue_code_attr_nameleaves them out, and elements still accept them).{{ ... }}inside a:prop on<c-slot>, in a fill'sv-slot, and in a Vue binding on a component tag, and the "must be written in the template with a plain text value" checks. These are template-author mistakes about a binding's value.docs/design/vue.mdsays "interpolation in a written binding fails as a template error", and the parser rejects the slot and fill forms withSyntaxError.refset from Python data on a component tag.Found while reviewing, not changed
None of these reaches the browser, and none is a
RuntimeErrorpath:c-bindkey that starts with#c-(anddata-cev-*orx-on:*keys) is accepted as slot data on<c-slot>, while component tags,<c-fill>and the built-in tags refuse it. Slot data stays on the server..,@, or:written as an attribute in the template (<c-slot .="v" />,<c-child @="v" />) passes the parser, because the grammar and thelen(key) > 1guard in_vue_directive_nameaccept it. Only the template author can write it._reject_vue_code_from_attrs_hookcompares keys withkey in before, which uses a key's own__eq__and__hash__. Hooks are extension code, which is already trusted.Docs, comments and changelog
The
VueCodeErrordocstring, the docs (vue/slots.md,vue/csp.md) anddocs/design/vue.mdsay where<c-slot>and<c-fill>raise it.CHANGELOG.mdhas two**Breaking:**entries under Unreleased (the exception type change, and the newly refused names) and one line under Fixes forstrsubclass keys.Checklist
CHANGELOG.mdupdatedChecks run: the full
packages/py/citry/testssuite without browser tests (12389 passed),ruff check,ruff format --check, andmypy packages/py/citry/citry(also with--platform linux). The new tests fail with the source change reverted, and the two__eq__tests fail whenexact_stris removed from the slot and fill loops. The fullscripts/check.pygate was not run.packages/py/citry_uitests: 3339 passed and 1 failed,test_the_editor_accepts_digit_inputs_as_text_or_numbers, which runs thetylanguage analyzer against the installed package and does not load this branch's code.🤖 Generated with Claude Code