AUR0723
Template compilation error: Invalid comma-separated class binding syntax in yyyy. It resulted in no valid class names after parsing.
Error message
Template compilation error: Invalid comma-separated class binding syntax in {{0}}. It resulted in no valid class names after parsing.
Parameters
target
: The invalid comma-separated string provided as the target for the.class
binding command.
Error explanation
This error occurs when using the .class
binding command with a comma-separated list of class names as the target, but the list is invalid or results in no actual class names after processing. This typically happens if the string contains only commas or whitespace between commas.
The .class
binding command allows specifying multiple static classes along with the dynamic binding, like my-class,another-class.class="expression"
. The part before .class
is split by commas, and each part should be a valid class name.
Common causes
Providing only commas or whitespace as the target for
.class
(e.g.,, .class="expr"
).Having trailing or leading commas without valid class names in between (e.g.,
my-class,.class="expr"
).
How to fix
Ensure that if you use a comma-separated list for the
.class
binding target, it contains valid class names separated by commas.Remove unnecessary commas or whitespace.
If you only intend to bind dynamically without static classes, use
class.bind="expression"
instead of.class="expression"
.
Example of Incorrect Usage:
<!-- Error: Only a comma before .class -->
<div ,.class="isActive ? 'active' : ''"></div>
<!-- Error: Comma with whitespace before .class -->
<div , .class="isActive ? 'active' : ''"></div>
<!-- Error: Trailing comma -->
<div my-static-class,.class="isActive ? 'active' : ''"></div>
Example of Correct Usage:
<!-- Binding dynamic class only -->
<div class.bind="isActive ? 'active' : ''"></div>
<!-- Binding dynamic class with one static class -->
<div my-static-class.class="isActive ? 'active' : ''"></div>
<!-- Binding dynamic class with multiple static classes -->
<div my-static-class,another-one.class="isActive ? 'active' : ''"></div>
Last updated
Was this helpful?