Skip to content

Commit

Permalink
feat: add jsx list
Browse files Browse the repository at this point in the history
  • Loading branch information
andycall committed Jun 23, 2022
1 parent bc63ccd commit 0a63389
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 4,799 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ dist

# TernJS port file
.tern-port

package-lock.json
12 changes: 12 additions & 0 deletions __tests__/__fixtures__/example/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createElement } from 'react';

function Foo() {
return (
<View>
<View x-for={array}>hello</View>
<View x-for={item in array}>item: {item}</View>
<View x-for={(item, key) in foo}>key: {key}, item: {item}</View>
<View x-for={(item, key) in exp()}>key: {key}, item: {item}</View>
</View>
)
}
14 changes: 14 additions & 0 deletions __tests__/__fixtures__/example/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createList as __create_list__ } from "babel-runtime-jsx-plus";
import { createElement } from "react";
function Foo() {
return /*#__PURE__*/ React.createElement(View, null, __create_list__.call(this, array, function() {
return React.createElement(View, null, "hello");
}), __create_list__.call(this, array, function(item) {
return React.createElement(View, null, "item: ", item);
}), __create_list__.call(this, foo, function(item, key) {
return React.createElement(View, null, "key: ", key, ", item: ", item);
}), __create_list__.call(this, exp(), function(item, key) {
return React.createElement(View, null, "key: ", key, ", item: ", item);
}));
}

11 changes: 11 additions & 0 deletions __tests__/__fixtures__/side-effects/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const items = [1, 2, 3, 4];

export default function List() {
return (
<div>
<div x-for={(it, idx) in items}>
<span>{it}</span>
</div>
</div>
);
}
13 changes: 13 additions & 0 deletions __tests__/__fixtures__/side-effects/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createList as __create_list__ } from "babel-runtime-jsx-plus";
var items = [
1,
2,
3,
4
];
export default function List() {
return /*#__PURE__*/ React.createElement("div", null, __create_list__.call(this, items, function(it, idx) {
return React.createElement("div", null, /*#__PURE__*/ React.createElement("span", null, it));
}));
};

Loading

0 comments on commit 0a63389

Please sign in to comment.