Skip to content

Commit 0bce7ad

Browse files
authored
Merge pull request #36 from Paneon/bugfix/props
Fixes: #35
2 parents 5e7690a + 71078ea commit 0bce7ad

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/Compiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function registerProperties(DOMElement $scriptElement)
278278
}
279279
}
280280

281-
$typeScriptRegexProps = '/\@Prop\(.*?default\s*\:\s*(\'(?:.(?!(?<![\\\\])\'))*.?\'|"(?:.(?!(?<![\\\\])"))*.?"|[^\s,]+).*?\)[^;]*?([a-zA-Z0-9_$]+)\!?\:[^;]*;/msx';
281+
$typeScriptRegexProps = '/\@Prop\(.*?default\s*\:\s*(?<defaultValue>\'(?:[^@](?!(?<![\\\\])\'))*.?\'|"(?:[^@](?!(?<![\\\\])"))*.?"|[^\s,]+).*?\)[^;]*?(?<propName>[a-zA-Z0-9_$]+)\!?\:[^;\@]*;/msx';
282282

283283
if (preg_match_all($typeScriptRegexProps, $content, $typeScriptMatches, PREG_SET_ORDER )) {
284284
$this->properties = [];

tests/CompilerPropsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ public function registersTypeScriptProperties()
3939

4040
$this->assertEqualHtml($expected, $actual);
4141
}
42+
4243
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
{% set test = test|default('foo') %}
1+
{% set propBoolean = propBoolean|default(false) %}
2+
{% set propPresent = propPresent|default('') %}
3+
{% set propWithTypeNumber = propWithTypeNumber|default(0) %}
4+
{% set propPresentWithTypeAndDefault = propPresentWithTypeAndDefault|default('foo') %}
25
<div class="{{class|default('')}}">
36
{{ test }}
47
</div>
8+
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<template>
2-
<div>
3-
{{ test }}
4-
</div>
2+
<div>
3+
{{ test }}
4+
</div>
55
</template>
66

77
<script lang="ts">
8-
import { Vue, Component, Prop } from 'vue-property-decorator';
8+
import { Component, Prop, Vue } from 'vue-property-decorator';
99
10-
@Component
11-
export default class FromPrice extends Vue {
12-
@Prop({ type: String, default: 'foo' }) readonly test!: string;
13-
}
10+
@Component
11+
export default class FromPrice extends Vue {
12+
@Prop({ type: Boolean, required: true }) ignored: boolean;
13+
@Prop({ default: false }) propBoolean: string;
14+
@Prop({ default: '' }) propPresent!: string;
15+
@Prop({ default: 0, type: Number }) propWithTypeNumber!: number;
16+
@Prop({ type: String, default: 'foo' }) readonly propPresentWithTypeAndDefault!: string;
17+
}
1418
</script>

0 commit comments

Comments
 (0)