Skip to content

Commit

Permalink
revert: foreach to use fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
jodarove committed Sep 15, 2022
1 parent 75b21e4 commit 5f3c264
Show file tree
Hide file tree
Showing 49 changed files with 763 additions and 872 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<x-comments-foreach>
<template shadowroot="open">
<ul>
<!-- color -->
<li>
red
Expand All @@ -14,7 +13,6 @@
<li>
yellow
</li>
</ul>
</template>
</x-comments-foreach>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<x-for-each-block>
<template shadowroot="open">
<ul>
<li>
0 - paris
</li>
Expand All @@ -11,7 +10,6 @@
<li>
2 - tokyo
</li>
</ul>
</template>
</x-for-each-block>
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<x-for-each-child-nested>
<template shadowroot="open">
<ol>
<li>
europe
<x-child>
<template shadowroot="open">
<li>
0 - paris
</li>
Expand All @@ -16,15 +14,13 @@
<li>
2 - rome
</li>
</template>
</x-child>
</li>
<li>
asia
<x-child>
<template shadowroot="open">
<li>
0 - tokyo
</li>
Expand All @@ -34,11 +30,9 @@
<li>
2 - singapore
</li>
</template>
</x-child>
</li>
</ol>
</template>
</x-for-each-child-nested>
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<x-for-each-nested>
<template shadowroot="open">
<ol>
<li>
europe
<ul>
<li>
paris
</li>
Expand All @@ -15,13 +13,11 @@
<li>
rome
</li>
</ul>
</li>
<li>
asia
<ul>
<li>
tokyo
</li>
Expand All @@ -31,10 +27,8 @@
<li>
singapore
</li>
</ul>
</li>
</ol>
</template>
</x-for-each-nested>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<x-getter-is-connected>
<template shadowroot="open">
<ul>
<li>
constructor: false
</li>
Expand All @@ -11,7 +10,6 @@
<li>
render: true
</li>
</ul>
</template>
</x-getter-is-connected>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<x-iterator-block>
<template shadowroot="open">
<ul>
<li>
<div class="list-first">
</div>
Expand All @@ -15,7 +14,6 @@
<div class="list-last">
</div>
</li>
</ul>
</template>
</x-iterator-block>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<x-lifecycle-hooks>
<template shadowroot="open">
<ul>
<li>
constructor
</li>
Expand All @@ -11,7 +10,6 @@
<li>
render
</li>
</ul>
</template>
</x-lifecycle-hooks>
14 changes: 7 additions & 7 deletions packages/@lwc/template-compiler/src/__tests__/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ describe('customRendererConfig normalization', () => {
},
})
).toMatchInlineSnapshot(`
Object {
"customRendererConfig": Object {
"directives": Array [],
"elements": Array [
Object {
{
"customRendererConfig": {
"directives": [],
"elements": [
{
"attributes": undefined,
"namespace": undefined,
"tagName": "div",
},
Object {
"attributes": Array [
{
"attributes": [
"style",
],
"namespace": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function tmpl($api, $cmp, $slotset, $ctx) {
h: api_element,
k: api_key,
i: api_iterator,
fr: api_fragment,
f: api_flatten,
} = $api;
return [
return api_flatten([
api_custom_element("x-subject", _xSubject, {
props: {
htmlFor: api_scoped_id("foo"),
Expand Down Expand Up @@ -54,30 +54,27 @@ function tmpl($api, $cmp, $slotset, $ctx) {
},
key: 5,
}),
api_fragment(
"it-fr8",
api_iterator($cmp.things, function (thing) {
return [
api_element(
"p",
{
attrs: {
id: api_scoped_id(thing.id),
},
key: api_key(6, thing.key),
},
[api_text("description text")]
),
api_element("input", {
api_iterator($cmp.things, function (thing) {
return [
api_element(
"p",
{
attrs: {
"aria-describedby": api_scoped_id(thing.id),
id: api_scoped_id(thing.id),
},
key: api_key(7, thing.key),
}),
];
})
),
];
key: api_key(6, thing.key),
},
[api_text("description text")]
),
api_element("input", {
attrs: {
"aria-describedby": api_scoped_id(thing.id),
},
key: api_key(7, thing.key),
}),
];
}),
]);
/*LWC compiler vX.X.X*/
}
export default registerTemplate(tmpl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,24 @@ const stc0 = {
svg: true,
};
function tmpl($api, $cmp, $slotset, $ctx) {
const {
k: api_key,
h: api_element,
i: api_iterator,
fr: api_fragment,
} = $api;
const { k: api_key, h: api_element, i: api_iterator } = $api;
return [
api_element("svg", stc0, [
api_fragment(
"it-fr2",
api_iterator($cmp.lines, function (line) {
return api_element("line", {
attrs: {
x1: line.x1,
y1: line.y1,
x2: line.x2,
y2: line.y2,
},
key: api_key(1, line.key),
svg: true,
});
})
),
]),
api_element(
"svg",
stc0,
api_iterator($cmp.lines, function (line) {
return api_element("line", {
attrs: {
x1: line.x1,
y1: line.y1,
x2: line.x2,
y2: line.y2,
},
key: api_key(1, line.key),
svg: true,
});
})
),
];
/*LWC compiler vX.X.X*/
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,24 @@ function tmpl($api, $cmp, $slotset, $ctx) {
t: api_text,
h: api_element,
i: api_iterator,
fr: api_fragment,
} = $api;
return [
api_element("ul", stc0, [
api_fragment(
"it-fr2",
api_iterator($cmp.colors, function (color) {
return [
api_comment(" color "),
api_element(
"li",
{
key: api_key(1, color),
},
[api_text(api_dynamic_text(color))]
),
];
})
),
]),
api_element(
"ul",
stc0,
api_iterator($cmp.colors, function (color) {
return [
api_comment(" color "),
api_element(
"li",
{
key: api_key(1, color),
},
[api_text(api_dynamic_text(color))]
),
];
})
),
];
/*LWC compiler vX.X.X*/
}
Expand Down
Loading

0 comments on commit 5f3c264

Please sign in to comment.