mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
Merge pull request #44 from anchann/rt-scope-trailing-semicolon
Allow trailing semicolon in rt-scope
This commit is contained in:
commit
b79ed7a040
@ -293,6 +293,8 @@ function convertHtmlToReact(node, context) {
|
||||
data.scopeMapping[boundParam] = boundParam;
|
||||
});
|
||||
_.each(node.attribs[scopeProp].split(';'), function (scopePart) {
|
||||
if (scopePart.trim().length === 0) return;
|
||||
|
||||
var scopeSubParts = scopePart.split(' as ');
|
||||
if (scopeSubParts.length < 2) {
|
||||
throw RTCodeError.build("invalid scope part '" + scopePart + "'", context, node);
|
||||
|
6
test/data/scope-trailing-semicolon.rt
Normal file
6
test/data/scope-trailing-semicolon.rt
Normal file
@ -0,0 +1,6 @@
|
||||
<div>
|
||||
<div rt-scope="15 as a; 20 as b;">
|
||||
{a + b}
|
||||
</div>
|
||||
<div rt-if="typeof a === 'undefined'">good</div>
|
||||
</div>
|
2
test/data/scope-trailing-semicolon.rt.html
Normal file
2
test/data/scope-trailing-semicolon.rt.html
Normal file
@ -0,0 +1,2 @@
|
||||
<div><div>35</div><div>good</div></div>
|
||||
|
@ -175,7 +175,7 @@ function normalizeHtml(html) {
|
||||
}
|
||||
|
||||
test('html tests', function (t) {
|
||||
var files = ['scope.rt', 'lambda.rt', 'eval.rt', 'props.rt', 'custom-element.rt', 'style.rt', 'concat.rt', 'js-in-attr.rt', 'props-class.rt', 'rt-class.rt'];
|
||||
var files = ['scope.rt', 'scope-trailing-semicolon.rt', 'lambda.rt', 'eval.rt', 'props.rt', 'custom-element.rt', 'style.rt', 'concat.rt', 'js-in-attr.rt', 'props-class.rt', 'rt-class.rt'];
|
||||
t.plan(files.length);
|
||||
|
||||
files.forEach(check);
|
||||
|
Loading…
x
Reference in New Issue
Block a user