Skip to content

Commit a4aa825

Browse files
committed
Use refactorCondition on the conditions of the object binding
1 parent 8f6bc33 commit a4aa825

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/Compiler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ private function handleAttributeBinding(DOMElement $node)
228228

229229
foreach ($items as $item) {
230230
if(preg_match($regexObjectElements, $item, $matchElement)){
231-
$dynamicValues[] = sprintf('{{ %s ? \'%s\' }}', $matchElement['condition'], $matchElement['class']);
231+
$dynamicValues[] = sprintf(
232+
'{{ %s ? \'%s\' }}',
233+
$this->builder->refactorCondition($matchElement['condition']),
234+
$matchElement['class']
235+
);
232236
}
233237
}
234238

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' }} {{ isSomething ? 'block2' }}"></div>
6+
<div class="category-filter-list categories {{ isSomething ? 'block' }} {{ not isSomething ? 'block2' }}"></div>
77
</div>
88
</div>

tests/fixtures/vue-bind/bindings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<input type="radio" :checked="true">
55
<img :src="imageSrc">
66
<div :class="['a', 'b', 'c']"></div>
7-
<div :class="{ 'block': isSomething, 'block2': isSomething}" class="category-filter-list categories"></div>
7+
<div :class="{ 'block': isSomething, 'block2': !isSomething}" class="category-filter-list categories"></div>
88
</div>
99
</div>
1010
</template>

0 commit comments

Comments
 (0)