Skip to content

fix: slots work in Safari #230

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

Merged
merged 3 commits into from
Mar 22, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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