Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(template-compiler): implement handling for scoped slot directives in template #3077

Merged
merged 24 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
52f0d2f
test: initial set of tests for scoped slots
ravijayaramappa Sep 30, 2022
45c217d
feat: add handling of lwc:data-bind directive
ravijayaramappa Oct 2, 2022
90b9b0e
feat: add handling for lwc:slot-data directive
ravijayaramappa Oct 2, 2022
3c90967
fix: create SlotData directive node for continuity
ravijayaramappa Oct 3, 2022
4b9166d
fix: change warning to error
ravijayaramappa Oct 5, 2022
e0e49fe
feat: add capability in engine to accept a factory function as slot c…
ravijayaramappa Oct 5, 2022
3cd6be4
test: update tests after rebase
ravijayaramappa Oct 5, 2022
812ff70
test: update error message
ravijayaramappa Oct 5, 2022
3e51fa9
feat: add code gen for scoped slots
ravijayaramappa Oct 5, 2022
188e84f
fix: formatting a file
ravijayaramappa Oct 5, 2022
94edd67
test: basic karma test with default slot
ravijayaramappa Oct 5, 2022
3be71d6
test: test case with forEach
ravijayaramappa Oct 6, 2022
505e592
test: more tests for bindings and nested slots
ravijayaramappa Oct 6, 2022
4a426fe
fix: address review feedback
ravijayaramappa Oct 11, 2022
3576c5e
test: more tests for duplicates detection
ravijayaramappa Oct 12, 2022
1bbcbb4
fix: revert fixtures setup
ravijayaramappa Oct 12, 2022
21e7c11
fix: address PMs review comments
ravijayaramappa Oct 12, 2022
54ef4b5
fix: update fixture files
ravijayaramappa Oct 12, 2022
7840bfa
test: missing negative test cases
ravijayaramappa Oct 13, 2022
3a4edf5
fix: address PMs review comments
ravijayaramappa Oct 13, 2022
2a95159
fix: shuffle order of arugments in ssf api
ravijayaramappa Oct 13, 2022
1798af7
fix: update todo with issue id
ravijayaramappa Oct 13, 2022
ce36e81
test: add tests for ssr
ravijayaramappa Oct 14, 2022
8313089
fix: address pr comments from james
ravijayaramappa Oct 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: update tests after rebase
  • Loading branch information
ravijayaramappa committed Oct 11, 2022
commit 3cd6be43d66f08ff1678f942cb79c770e7aa3176
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ export const ParserDiagnostics = {

SLOT_TAG_CANNOT_HAVE_DIRECTIVES: {
code: 1082,
message: "Slot tag can't be associated with for:each, for:of or if:true/false directives",
message:
"Slot tag can't be associated with for:each, for:of, if:true, if:flase, lwc:if, lwc:else, lwc:elseif template directives.",

This comment was marked as resolved.

This comment was marked as resolved.

level: DiagnosticLevel.Error,
url: '',
},
Expand Down Expand Up @@ -723,14 +724,14 @@ export const ParserDiagnostics = {
level: DiagnosticLevel.Error,
url: '',
},

INVALID_ELSEIF_BLOCK_DIRECTIVE_WITH_CONDITIONAL: {
code: 1163,
message: "Invalid usage of 'lwc:elseif' and '{0}' directives on the same element.",
level: DiagnosticLevel.Error,
url: '',
},

INVALID_ELSE_BLOCK_DIRECTIVE_WITH_CONDITIONAL: {
code: 1164,
message: "Invalid usage of 'lwc:else' and '{0}' directives on the same element.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"warnings": [
{
"code": 1082,
"message": "LWC1082: Slot tag can't be associated with directives",
"message": "LWC1082: Slot tag can't be associated with for:each, for:of or if:true/false directives",
"level": 1,
"location": {
"line": 2,
Expand All @@ -13,7 +13,7 @@
},
{
"code": 1082,
"message": "LWC1082: Slot tag can't be associated with directives",
"message": "LWC1082: Slot tag can't be associated with for:each, for:of or if:true/false directives",
"level": 1,
"location": {
"line": 3,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,269 @@
{}
{
"root": {
"type": "Root",
"location": {
"startLine": 1,
"startColumn": 1,
"endLine": 5,
"endColumn": 12,
"start": 0,
"end": 214,
"startTag": {
"startLine": 1,
"startColumn": 1,
"endLine": 1,
"endColumn": 35,
"start": 0,
"end": 34
},
"endTag": {
"startLine": 5,
"startColumn": 1,
"endLine": 5,
"endColumn": 12,
"start": 203,
"end": 214
}
},
"directives": [
{
"type": "Directive",
"name": "RenderMode",
"value": {
"type": "Literal",
"value": "light"
},
"location": {
"startLine": 1,
"startColumn": 11,
"endLine": 1,
"endColumn": 34,
"start": 10,
"end": 33
}
}
],
"children": [
{
"type": "Slot",
"name": "slot",
"namespace": "http://www.w3.org/1999/xhtml",
"slotName": "slotname1",
"location": {
"startLine": 2,
"startColumn": 5,
"endLine": 2,
"endColumn": 61,
"start": 39,
"end": 95,
"startTag": {
"startLine": 2,
"startColumn": 5,
"endLine": 2,
"endColumn": 54,
"start": 39,
"end": 88
},
"endTag": {
"startLine": 2,
"startColumn": 54,
"endLine": 2,
"endColumn": 61,
"start": 88,
"end": 95
}
},
"attributes": [
{
"type": "Attribute",
"name": "name",
"value": {
"type": "Literal",
"value": "slotname1"
},
"location": {
"startLine": 2,
"startColumn": 11,
"endLine": 2,
"endColumn": 27,
"start": 45,
"end": 61
}
}
],
"properties": [],
"directives": [
{
"type": "Directive",
"name": "SlotBind",
"value": {
"type": "Identifier",
"start": 1,
"end": 10,
"name": "slot1data",
"location": {
"startLine": 2,
"startColumn": 28,
"endLine": 2,
"endColumn": 53,
"start": 62,
"end": 87
}
},
"location": {
"startLine": 2,
"startColumn": 28,
"endLine": 2,
"endColumn": 53,
"start": 62,
"end": 87
}
}
],
"listeners": [],
"children": []
},
{
"type": "Slot",
"name": "slot",
"namespace": "http://www.w3.org/1999/xhtml",
"slotName": "slotname2",
"location": {
"startLine": 3,
"startColumn": 5,
"endLine": 3,
"endColumn": 61,
"start": 100,
"end": 156,
"startTag": {
"startLine": 3,
"startColumn": 5,
"endLine": 3,
"endColumn": 54,
"start": 100,
"end": 149
},
"endTag": {
"startLine": 3,
"startColumn": 54,
"endLine": 3,
"endColumn": 61,
"start": 149,
"end": 156
}
},
"attributes": [
{
"type": "Attribute",
"name": "name",
"value": {
"type": "Literal",
"value": "slotname2"
},
"location": {
"startLine": 3,
"startColumn": 11,
"endLine": 3,
"endColumn": 27,
"start": 106,
"end": 122
}
}
],
"properties": [],
"directives": [
{
"type": "Directive",
"name": "SlotBind",
"value": {
"type": "Identifier",
"start": 1,
"end": 10,
"name": "slot2data",
"location": {
"startLine": 3,
"startColumn": 28,
"endLine": 3,
"endColumn": 53,
"start": 123,
"end": 148
}
},
"location": {
"startLine": 3,
"startColumn": 28,
"endLine": 3,
"endColumn": 53,
"start": 123,
"end": 148
}
}
],
"listeners": [],
"children": []
},
{
"type": "Slot",
"name": "slot",
"namespace": "http://www.w3.org/1999/xhtml",
"slotName": "",
"location": {
"startLine": 4,
"startColumn": 5,
"endLine": 4,
"endColumn": 46,
"start": 161,
"end": 202,
"startTag": {
"startLine": 4,
"startColumn": 5,
"endLine": 4,
"endColumn": 39,
"start": 161,
"end": 195
},
"endTag": {
"startLine": 4,
"startColumn": 39,
"endLine": 4,
"endColumn": 46,
"start": 195,
"end": 202
}
},
"attributes": [],
"properties": [],
"directives": [
{
"type": "Directive",
"name": "SlotBind",
"value": {
"type": "Identifier",
"start": 1,
"end": 12,
"name": "defaultdata",
"location": {
"startLine": 4,
"startColumn": 11,
"endLine": 4,
"endColumn": 38,
"start": 167,
"end": 194
}
},
"location": {
"startLine": 4,
"startColumn": 11,
"endLine": 4,
"endColumn": 38,
"start": 167,
"end": 194
}
}
],
"listeners": [],
"children": []
}
]
}
}
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,30 @@
import { registerTemplate } from "lwc";
const stc0 = {
attrs: {
name: "slotname1",
},
key: 0,
};
const stc1 = [];
const stc2 = {
attrs: {
name: "slotname2",
},
key: 1,
};
const stc3 = {
key: 2,
};
function tmpl($api, $cmp, $slotset, $ctx) {
const { s: api_slot, f: api_flatten } = $api;
return api_flatten([
api_slot("slotname1", stc0, stc1, $slotset),
api_slot("slotname2", stc2, stc1, $slotset),
api_slot("", stc3, stc1, $slotset),
]);
/*LWC compiler vX.X.X*/
}
export default registerTemplate(tmpl);
tmpl.slots = ["", "slotname1", "slotname2"];
tmpl.stylesheets = [];
tmpl.renderMode = "light";
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
{
"warnings": [
{
"code": 1159,
"message": "LWC1159: Invalid `lwc:slot-bind` usage. The \"Scoped Slots\" feature must be enabled in order to use this directive.",
"level": 1,
"location": {
"line": 2,
"column": 5,
"start": 39,
"length": 56
}
},
{
"code": 1159,
"message": "LWC1159: Invalid `lwc:slot-bind` usage. The \"Scoped Slots\" feature must be enabled in order to use this directive.",
"level": 1,
"location": {
"line": 3,
"column": 5,
"start": 100,
"length": 56
}
},
{
"code": 1159,
"message": "LWC1159: Invalid `lwc:slot-bind` usage. The \"Scoped Slots\" feature must be enabled in order to use this directive.",
"level": 1,
"location": {
"line": 4,
"column": 5,
"start": 161,
"length": 41
}
}
]
"warnings": []
}
Loading