Skip to content

Commit

Permalink
Use refactorCondition on the conditions of the object binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Macavity committed Feb 21, 2019
1 parent 8f6bc33 commit a4aa825
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ private function handleAttributeBinding(DOMElement $node)

foreach ($items as $item) {
if(preg_match($regexObjectElements, $item, $matchElement)){
$dynamicValues[] = sprintf('{{ %s ? \'%s\' }}', $matchElement['condition'], $matchElement['class']);
$dynamicValues[] = sprintf(
'{{ %s ? \'%s\' }}',
$this->builder->refactorCondition($matchElement['condition']),
$matchElement['class']
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/vue-bind/bindings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<input type="radio" checked>
<img src="{{imageSrc}}">
<div class="a b c"></div>
<div class="category-filter-list categories {{ isSomething ? 'block' }} {{ isSomething ? 'block2' }}"></div>
<div class="category-filter-list categories {{ isSomething ? 'block' }} {{ not isSomething ? 'block2' }}"></div>
</div>
</div>
2 changes: 1 addition & 1 deletion tests/fixtures/vue-bind/bindings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<input type="radio" :checked="true">
<img :src="imageSrc">
<div :class="['a', 'b', 'c']"></div>
<div :class="{ 'block': isSomething, 'block2': isSomething}" class="category-filter-list categories"></div>
<div :class="{ 'block': isSomething, 'block2': !isSomething}" class="category-filter-list categories"></div>
</div>
</div>
</template>

0 comments on commit a4aa825

Please sign in to comment.