-
Notifications
You must be signed in to change notification settings - Fork 10
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
resolve multiple <slot> elements rendering on the home page #454
resolve multiple <slot> elements rendering on the home page #454
Conversation
ee60fe0
to
9b055a3
Compare
@aholtzman |
www/components/card/card.js
Outdated
${this.renderImage()} | ||
${this.renderTitle()} | ||
<slot name="cardcontent"></slot> | ||
<div class="gwd-card"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this wont work for yarn serve
because this moves the <slot>
away from being a direct descendent of the :host
😞
Something else i've come to realize about this issue is that when we pre-render a web component, the final HTML is not just the tags <my-component></my-component> but the tags plus whatever its contents render out to, e.g. <my-component>
<header>
<h1>Lorum Ipsum</h1>
<!-- etc -->
</header>
</my-component> The issue being that this pre-rendered markup is light DOM. When a web component mounts, it will by default attach a ShadowDOM. This means it will have both light and shadow DOM. This becomes an issue now because the light dom will now compete with the content projected into the Shadow DOM via So short term there are some best practices and "rules" we can document for when |
* initial WIP to resolve the issue * example code cleanup * supplemental documentation for Shadow DOM and slot usage * restore card padding * fix padding, revert slot to direct decendent of host * remove extra dependency * home page card style tweaks Co-authored-by: aholtzman <[email protected]>
* initial WIP to resolve the issue * example code cleanup * supplemental documentation for Shadow DOM and slot usage * restore card padding * fix padding, revert slot to direct decendent of host * remove extra dependency * home page card style tweaks Co-authored-by: aholtzman <[email protected]>
Related Issue
resolves #433
Summary of Changes
Did some experimentation and comparisons between
HTMLElement
andLitElement
(you can compare in the home page index.html right now).From my research I learned / observed a couple interesting insights into Shadow DOM /
<slot>
<slot>
s should be namedThey only seem to support a shallow level of nesting, even when using
name
, nativeHTMLElement
andyarn develop
(notice the third<slot>
doesn't render)So just had to do a little refactoring to our website HTML to better honor these rules.
<app-row>
component to reduce extraneous nesting. _why use more JS when few JS do trickTODO
<slot>
best practices, probably best to after merge of Docs/issue 430 update technical documentation to reflect current project status #452<slot-test-native>
example code after team review