mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
Merge pull request #89 from nippur72/safe-parsing
Correctly parse rt-repeat object literal collection
This commit is contained in:
commit
b67efbf278
@ -346,7 +346,7 @@ function convertHtmlToReact(node, context) {
|
||||
data.item = arr[0].trim();
|
||||
data.collection = arr[1].trim();
|
||||
validateJS(data.item, node, context);
|
||||
validateJS(data.collection, node, context);
|
||||
validateJS("(" + data.collection + ")", node, context);
|
||||
stringUtils.addIfMissing(context.boundParams, data.item);
|
||||
stringUtils.addIfMissing(context.boundParams, `${data.item}Index`);
|
||||
}
|
||||
|
5
test/data/repeat-literal-collection.rt
Normal file
5
test/data/repeat-literal-collection.rt
Normal file
@ -0,0 +1,5 @@
|
||||
<div>
|
||||
<div rt-repeat="items in {a:1, b:2}">
|
||||
{items}
|
||||
</div>
|
||||
</div>
|
1
test/data/repeat-literal-collection.rt.html
Normal file
1
test/data/repeat-literal-collection.rt.html
Normal file
@ -0,0 +1 @@
|
||||
<div><div>1</div><div>2</div></div>
|
@ -184,7 +184,7 @@ test('convert jsrt and test source results', function (t) {
|
||||
test('html tests', function (t) {
|
||||
var files = ['scope.rt', 'scope-trailing-semicolon.rt', 'scope-variable-references.rt', 'lambda.rt', 'eval.rt', 'props.rt', 'custom-element.rt', 'style.rt', 'concat.rt',
|
||||
'js-in-attr.rt', 'props-class.rt', 'rt-class.rt', 'className.rt', 'svg.rt',
|
||||
'scope-evaluated-after-repeat.rt', 'scope-evaluated-after-repeat2.rt', 'scope-evaluated-after-if.rt', 'scope-obj.rt'
|
||||
'repeat-literal-collection.rt', 'scope-evaluated-after-repeat.rt', 'scope-evaluated-after-repeat2.rt', 'scope-evaluated-after-if.rt', 'scope-obj.rt'
|
||||
];
|
||||
t.plan(files.length);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user