Allow trailing semicolon in rt-scope
Rationale: it is natural for many developers to place a trailing semicolon after the last scope alias pair, just as they do after every preceding pair in the list. Since it is possible to save them time (and perhaps frustration) at no cost in terms of semantics and safety, we should do so. On tests. Wasn't sure if this should be broken out into a separate test, or bundled together with the existing one.
This commit is contained in:
parent
cee215c081
commit
88dc5544e8
|
@ -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);
|
||||
|
|
|
@ -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>
|
|
@ -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…
Reference in New Issue