core
core copied to clipboard
refactor(compiler): add dedicated transform for vbind shorthand
close #13169 close #13170 close #11321 close #12298 close #12828
use tests from #13170 and #12298 and #12828
The current handing logic for v-bind shorthand is rather scattered, which results in many edge cases where transformBindShorthand needs to be called additionally. these cases occur because vbind shorthand has not been processed when reading properties from props.
This PR introduces a dedicated transform specifically for handling v-bind shorthand, and makes it the first transform to be called. This ensures that vbind shorthand has already been processed before any subsequent logic read from props
Special handling is required for double bind in vue-macros. PR https://github.com/vue-macros/vue-macros/pull/960
Summary by CodeRabbit
-
New Features
- Added support for shorthand v-bind syntax (e.g.,
:prop) across the template compiler, including server-side rendering. - Exposed the shorthand v-bind transform for public use.
- Added support for shorthand v-bind syntax (e.g.,
-
Bug Fixes
- Correctly handles shorthand v-bind directives in combination with other directives like v-if, v-for, and v-model.
-
Tests
- Added and updated test cases to ensure proper handling of shorthand v-bind syntax in various scenarios, including dynamic tags and v-model.
-
Documentation
- No end-user documentation changes included.
-
Chores
- Minor internal refactoring and public export of a utility regular expression.