--- title: Dynamic Directive Arguments Have Syntax Constraints impact: MEDIUM impactDescription: Invalid dynamic arguments cause silent failures or browser compatibility issues type: capability tags: [vue3, template, directives, v-bind, v-on, dynamic-arguments] --- # Dynamic Directive Arguments Have Syntax Constraints **Impact: MEDIUM** - Dynamic directive arguments (e.g., `:[attributeName]`, `@[eventName]`) have value and syntax constraints that can cause silent failures. In-DOM templates also have case sensitivity issues with browsers lowercasing attribute names. Dynamic arguments allow runtime determination of which attribute or event to bind, but they have restrictions that differ from static arguments. ## Task Checklist - [ ] Ensure dynamic arguments evaluate to strings or `null` - [ ] Avoid spaces and quotes inside dynamic argument brackets - [ ] Use computed properties for complex dynamic argument expressions - [ ] In in-DOM templates, use lowercase attribute names or switch to SFCs - [ ] Use `null` to explicitly remove a binding **Incorrect:** ```vue Link Link Link Link Link ``` **Correct:** ```vue Link Link Link ``` ## In-DOM Template Workaround When writing templates directly in HTML (not SFCs), use lowercase: ```html
``` ## SFC vs In-DOM Templates | Feature | SFC (.vue files) | In-DOM (HTML) | |---------|------------------|---------------| | Case sensitivity | Preserved | Lowercased by browser | | Dynamic arguments | Full support | Lowercase only | | Recommendation | Preferred | Use for progressive enhancement | ## Valid Dynamic Argument Values ```vue ``` ## Reference - [Vue.js Template Syntax - Dynamic Arguments](https://vuejs.org/guide/essentials/template-syntax.html#dynamic-arguments) - [Vue.js Template Syntax - Dynamic Argument Value Constraints](https://vuejs.org/guide/essentials/template-syntax.html#dynamic-argument-value-constraints)