Skip to content

Commit 73545e5

Browse files
authored
Merge pull request #92 from tronsha/bugfix/props
Fix for v-bind="$props"
2 parents 32c971d + 41ef7d9 commit 73545e5

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/Compiler.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,13 @@ private function preparePropertiesForInclude(array $variables, bool $isRootNode
463463
);
464464
}
465465
} elseif ($name === 'vBind') {
466-
$this->vBind = $value;
466+
if ($value === '"$props"') {
467+
foreach ($this->properties as $property) {
468+
$variables[] = (clone $property)->setValue($property->getName());
469+
}
470+
} else {
471+
$this->vBind = $value;
472+
}
467473
unset($variables[$key]);
468474
}
469475
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% set foo = foo|default('foo') %}
2+
{% set bar = bar|default(42) %}
3+
<div class="{{ class|default('') }}" style="{{ style|default('') }}">
4+
{% include "/templates/ChildComponent.twig" with { 'slot_default': "", 'foo': foo, 'bar': bar, 'class': "", 'style': "" } %}
5+
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<div>
3+
<ChildComponent v-bind="$props" />
4+
</div>
5+
</template>
6+
7+
<script lang="ts">
8+
import { Component, Prop, Vue } from 'vue-property-decorator';
9+
10+
@Component
11+
export default class ComponentWithVBind extends Vue {
12+
@Prop({ type: String, default: 'foo' }) foo: string;
13+
@Prop({ type: Number, default: 42 }) bar: number;
14+
}
15+
</script>

0 commit comments

Comments
 (0)