Skip to content

Commit 27d07f6

Browse files
committed
Add space after dynamic class binding
1 parent aa638d3 commit 27d07f6

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/Compiler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public function convert(): string
8383
{
8484
$templateElement = $this->document->getElementsByTagName('template')->item(0);
8585
$scriptElement = $this->document->getElementsByTagName('script')->item(0);
86+
87+
/** @var \DOMNodeList $twigBlocks */
8688
$twigBlocks = $this->document->getElementsByTagName('twig');
8789

8890
if ($scriptElement) {
@@ -340,7 +342,7 @@ private function handleAttributeBinding(DOMElement $node)
340342
$dynamicValues[] = sprintf(
341343
'{{ %s ? \'%s\' }}',
342344
$this->builder->refactorCondition($matchElement['condition']),
343-
$matchElement['class']
345+
$matchElement['class'] . ' '
344346
);
345347
}
346348
}

tests/fixtures/vue-bind/bindings.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<input type="radio" checked>
44
<img src="{{imageSrc}}">
55
<div class="a b c"></div>
6-
<div class="category-filter-list categories {{ isSomething ? 'block' }} {{ not isSomething ? 'block2' }}"></div>
6+
<div class="category-filter-list categories {{ isSomething ? 'block ' }} {{ not isSomething ? 'block2 ' }}"></div>
77
</div>
88
</div>

tests/fixtures/vue-bind/double-attribute-binding.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
<div class="static1 static2 dynamic dynamic--{{ modifier }}">
33
Hello World
44
</div>
5+
<div class="static1 static2 {{ true ? 'my-class ' }}">
6+
With Object Binding
7+
</div>
58
</div>

tests/fixtures/vue-bind/double-attribute-binding.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
<div :class="`dynamic dynamic--${modifier}`" class="static1 static2">
44
Hello World
55
</div>
6+
<div :class="{ 'my-class': true }" class="static1 static2">
7+
With Object Binding
8+
</div>
69
</div>
710
</template>
811

0 commit comments

Comments
 (0)