Skip to content

Commit

Permalink
fix: slots work in Safari (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladitasev authored Mar 22, 2019
1 parent 0e8e460 commit 79445d0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/base/src/WebComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class WebComponent extends HTMLElement {
} else {
this._state[slot] = child;
}
child.setAttribute("slot", slotName);
});
}

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 79445d0

Please sign in to comment.