Skip to content

Commit 92a653f

Browse files
committed
Merge remote-tracking branch 'origin/feature/v-html' into feature/v-html
2 parents 8cf06f9 + 9667b70 commit 92a653f

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

src/Compiler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ 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>\'(?:[^\n](?!(?<![\\\\])\'))*.?\'|"(?:[^\n](?!(?<![\\\\])"))*.?"|[a-zA-Z0-9_]+).*?\)[^;]*?(?<propName>[a-zA-Z0-9_$]+)\!?\:[^;\@]*;/msx';
282282

283283
if (preg_match_all($typeScriptRegexProps, $content, $typeScriptMatches, PREG_SET_ORDER )) {
284284
$this->properties = [];
285285
foreach ($typeScriptMatches as $typeScriptMatch) {
286-
$property = new Property($typeScriptMatch[2], '', true);
287-
$property->setDefault(trim($typeScriptMatch[1]));
288-
$this->properties[$typeScriptMatch[2]] = $property;
286+
$property = new Property($typeScriptMatch['propName'], '', true);
287+
$property->setDefault(trim($typeScriptMatch['defaultValue']));
288+
$this->properties[$typeScriptMatch['propName']] = $property;
289289
}
290290
}
291291
}

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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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') %}
5+
{% set propPresentWithApostrophe = propPresentWithApostrophe|default('I\'m a text') %}
6+
{% set propPresentWithAt = propPresentWithAt|default('[email protected]') %}
27
<div class="{{class|default('')}}">
38
{{ test }}
49
</div>
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
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 PropsExample 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+
@Prop({ default: 'I\'m a text' }) readonly propPresentWithApostrophe!: string;
18+
@Prop({ default: '[email protected]' }) readonly propPresentWithAt!: string;
19+
}
1420
</script>

0 commit comments

Comments
 (0)