diff --git a/packages/base/src/WebComponent.js b/packages/base/src/WebComponent.js index 993ef7985abc..83088734bed5 100644 --- a/packages/base/src/WebComponent.js +++ b/packages/base/src/WebComponent.js @@ -170,7 +170,6 @@ class WebComponent extends HTMLElement { } else { this._state[slot] = child; } - child.setAttribute("slot", slotName); }); } @@ -382,12 +381,22 @@ class WebComponent extends HTMLElement { delete this._invalidated; ControlRenderer.render(this); + // Safari requires that children get the slot attribute only after the slot tags have been rendered in the shadow DOM + this._assignSlotsToChildren(); + // onAfterRendering if (typeof this.onAfterRendering === "function") { this.onAfterRendering(); } } + _assignSlotsToChildren() { + const domChildren = Array.from(this.children); + domChildren.filter(child => child._slot).forEach(child => { + child.setAttribute("slot", child._slot); + }); + } + _getTemplateContext() { return TemplateContext.calculate(this); }