Skip to content

Commit

Permalink
test: more tests for bindings and nested slots
Browse files Browse the repository at this point in the history
  • Loading branch information
ravijayaramappa committed Oct 11, 2022
1 parent 3be71d6 commit 505e592
Show file tree
Hide file tree
Showing 23 changed files with 1,018 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@lwc/errors/src/compiler/error-info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
/**
* Next error code: 1178
* Next error code: 1179
*/

export * from './compiler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,4 +838,11 @@ export const ParserDiagnostics = {
level: DiagnosticLevel.Error,
url: '',
},

INVALID_FOR_WITH_LWC_SLOT_DATA: {
code: 1178,
message: "Invalid usage of 'lwc:slot-data' in an iterator(for:each, for:of) block.",
level: DiagnosticLevel.Error,
url: '',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<x-list>
<template for:each={parentItems} for:item="parentItem" >
<div key={parentItem}>{parentItem}</div>
<template lwc:slot-data="item">
<span key={parentItem}>{item.id} - {item.name}</span>
</template>
</template>
</x-list>
<x-list>
<template for:each={parentItems} for:item="parentItem" >
<template lwc:slot-data="item">
<div key={parentItem}>{parentItem}</div>
<span key={parentItem}>{item.id} - {item.name}</span>
</template>
</template>
</x-list>
<template for:each={parentItems} for:item="parentItem" >
<x-list key={parentItem}>
<template lwc:slot-data="item">
<div>{parentItem}</div>
<span>{item.id} - {item.name}</span>
</template>
</x-list>
</template>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enableScopedSlots": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"warnings": [
{
"code": 1178,
"message": "LWC1178: Invalid usage of 'lwc:slot-data' in an iterator(for:each, for:of) block.",
"level": 1,
"location": {
"line": 5,
"column": 13,
"start": 154,
"length": 125
}
},
{
"code": 1178,
"message": "LWC1178: Invalid usage of 'lwc:slot-data' in an iterator(for:each, for:of) block.",
"level": 1,
"location": {
"line": 12,
"column": 13,
"start": 404,
"length": 182
}
},
{
"code": 1178,
"message": "LWC1178: Invalid usage of 'lwc:slot-data' in an iterator(for:each, for:of) block.",
"level": 1,
"location": {
"line": 20,
"column": 13,
"start": 728,
"length": 148
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<x-list>
<template for:each={parentItems} for:item="parentItem" lwc:slot-data="item">
<div>{parentItem}</div><span>{item.id} - {item.name}</span>
</template>
</x-list>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enableScopedSlots": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"warnings": [
{
"code": 1178,
"message": "LWC1178: Invalid usage of 'lwc:slot-data' in an iterator(for:each, for:of) block.",
"level": 1,
"location": {
"line": 3,
"column": 9,
"start": 32,
"length": 168
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<x-table data={data}>
<template lwc:slot-data="row">
<x-row row={row}> <!-- this is rendered for every row in the table -->
<template lwc:slot-data="column">
<span> <!-- this is rendered for every column in the row -->
Coordinates: {row.number} - {column.number} <!-- can refer to both `row` and `column` -->
</span>
</template>
</x-row>
</template>
</x-table>
</template>
Loading

0 comments on commit 505e592

Please sign in to comment.