Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/hip-goats-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure custom element styles append correctly during prod
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ export function client_component(analysis, options) {
state.hoisted.push(b.const('$$css', b.object([b.init('hash', hash), b.init('code', code)])));

component_block.body.unshift(
b.stmt(b.call('$.append_styles', b.id('$$anchor'), b.id('$$css')))
b.stmt(
b.call('$.append_styles', b.id('$$anchor'), b.id('$$css'), options.customElement && b.true)
)
);
}

Expand Down
5 changes: 3 additions & 2 deletions packages/svelte/src/internal/client/dom/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ var seen = new Set();
/**
* @param {Node} anchor
* @param {{ hash: string, code: string }} css
* @param {boolean} [is_custom_element]
*/
export function append_styles(anchor, css) {
export function append_styles(anchor, css, is_custom_element = false) {
// in dev, always check the DOM, so that styles can be replaced with HMR
if (!DEV) {
if (!DEV && !is_custom_element) {
if (seen.has(css)) return;
seen.add(css);
}
Expand Down