Closed AndrewRayCode closed 2 years ago
In LWC template, <template>
elements are considered as container elements should be associated with other directives like for:each
or if:*
. The <template>
elements aren't actually created in the DOM. Since those elements don't have an actual DOM representation, you can't assign standard attributes including slot
.
Makes sense. This adds some friction to the development process, because:
errorCallback
, so it's not obvious what went wrong<template>
tags are allowed in the markup and designed to look like other tags, but they have hidden restrictions, and there's no linting / static analysis to warn you about using them "wrong". Salesforce has countless one-off issues like this, but my understanding is LWCs are supposed to be an open source framework, not coupled to Salesforce's infrastructureMaybe I just need to learn the API better. Wanted to share my initial reaction to inconsistent template vs other tag usage
@AndrewRayCode this is interesting. So, you were planning to render a <template>
, giving it to some other component via a slot, but it will render no content in the UI. Yes, this is perfectly fine, but my question is: what is the other component supposed to be doing with that template? is the other component LWC? That's probably were the ball drops because receiving a template element in LWC is not super useful since you can't really clone that template and dump into an LWC.
In general, I'm sympathetic with the idea of loosing the restriction of the template elements in HTML files in LWC, and treat them as regular elements. @pmdartus we might have a path forward here without breaking people.
Description
Steps to Reproduce
Expected Results
This should work
Actual Results
The component crashes
Browsers Affected
All
Version
Salesforce