I'm trying to get the slotted item to fill the parents container in Safari. The following works in Chrome, FF, even Edge-Chromium, but not Safari. I only have ability to modify the content and styles of the slotted item and not the slot's container (i.e i can modify .c-name, but not user-card)
customElements.define( "user-card",
class extends HTMLElement {
connectedCallback() {
const randomHeight =
(Math.random() * 400 + 200)<<0;
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = `
<style>
.card {
display: flex;
flex-direction: column;
height: ${randomHeight}px;
}
.card > div {
flex: auto;
border: 1px solid blue;
}
</style>
<span>Height: ${randomHeight}px</span>
<div class="card">
<div class="card-header">Head</div>
<div class="card-content"><slot /></div>
<div class="card-footer">Foot</div>
</div>
`;
}
}
);
.c-name {
background: black;
color: white;
height: 100%;
}
<user-card>
<div class="c-name">
<span>John Smith</span>
</div>
</user-card>