-
Notifications
You must be signed in to change notification settings - Fork 405
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
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 45c217d
feat: add handling of lwc:data-bind directive
ravijayaramappa 90b9b0e
feat: add handling for lwc:slot-data directive
ravijayaramappa 3c90967
fix: create SlotData directive node for continuity
ravijayaramappa 4b9166d
fix: change warning to error
ravijayaramappa e0e49fe
feat: add capability in engine to accept a factory function as slot c…
ravijayaramappa 3cd6be4
test: update tests after rebase
ravijayaramappa 812ff70
test: update error message
ravijayaramappa 3e51fa9
feat: add code gen for scoped slots
ravijayaramappa 188e84f
fix: formatting a file
ravijayaramappa 94edd67
test: basic karma test with default slot
ravijayaramappa 3be71d6
test: test case with forEach
ravijayaramappa 505e592
test: more tests for bindings and nested slots
ravijayaramappa 4a426fe
fix: address review feedback
ravijayaramappa 3576c5e
test: more tests for duplicates detection
ravijayaramappa 1bbcbb4
fix: revert fixtures setup
ravijayaramappa 21e7c11
fix: address PMs review comments
ravijayaramappa 54ef4b5
fix: update fixture files
ravijayaramappa 7840bfa
test: missing negative test cases
ravijayaramappa 3a4edf5
fix: address PMs review comments
ravijayaramappa 2a95159
fix: shuffle order of arugments in ssf api
ravijayaramappa 1798af7
fix: update todo with issue id
ravijayaramappa ce36e81
test: add tests for ssr
ravijayaramappa 8313089
fix: address pr comments from james
ravijayaramappa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: update tests after rebase
- Loading branch information
commit 3cd6be43d66f08ff1678f942cb79c770e7aa3176
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
270 changes: 269 additions & 1 deletion
270
...ages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/child-named-slot/ast.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [] | ||
} | ||
] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...s/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/child-named-slot/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"enableScopedSlots": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
36 changes: 1 addition & 35 deletions
36
...@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/child-named-slot/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
Sorry, something went wrong.