[2.0.4] Nested Shadow DOM custom elements fail to upgrade in Safari when mounted inside non-custom-element templates
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
Hướng nghiên cứu
Start by tracing template(html, flag) and its create() path in @solidjs/web, then inspect the generated templates in the linked Playground example. Reproduce in Safari 26+ and compare how cloned nodes are adopted before and after insertion into the document. Done when nested custom elements upgrade in Safari as they do in Chrome and Firefox without breaking standard template cloning.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When a component renders a custom element (e.g. <x-outer />) inside a standard HTML element template from a parent component (e.g. <form><OuterField /></form>), any nested custom elements (<x-inner>) cloned inside <x-outer>'s Shadow DOM during its constructor() permanently fail to upgrade in Safari 26+ (inner.shadowRoot === null, inner.customElementRegistry === null).
Your Example Website or App
https://playground.solidjs.com/anonymous/59ad5fbf-f032-49ca-9e78-28632ddd6915
Steps to Reproduce the Bug or Issue
- Open https://playground.solidjs.com/anonymous/59ad5fbf-f032-49ca-9e78-28632ddd6915 in Safari 26+ (macOS).
- Observe the Preview pane:
"x-inner upgraded and rendered"is not rendered.- Output shows:
{ "innerUpgraded": false, "innerCustomElementRegistry": "null" }
- Open the exact same Playground URL in Chrome:
- "x-inner upgraded and rendered" renders in green.
- Output shows "innerUpgraded": true and "innerCustomElementRegistry": "[object CustomElementRegistry]".
Expected behavior
<x-inner> inside <x-outer>'s Shadow DOM should keep window.customElements as its customElementRegistry and upgrade when <form> is connected to document, matching Chrome and Firefox.
Screenshots or Videos
No response
Platform
- SolidJS:
2.0.4([email protected],@solidjs/[email protected]— also affectssolid-js/web1.xtemplate()) - OS: macOS 26.5.1
- Browser: Safari 26+ (AppleWebKit/605.1.15) — reproduces
- Chrome 146 / Firefox 161 — works as expected
Additional context
Root cause in @solidjs/web
In @solidjs/web's template(html, flag):
- For standard HTML templates (
flag !== 1, e.g._$template("<form>")),create()leaves the prototypenodeinsidet.content, sonode.ownerDocumentis the inert<template>document (customElementRegistry === null), andnode.cloneNode(true)returns a detached element still owned by that inert document. - For custom-element templates (
flag === 1, e.g._$template("<x-outer>", 1)), Solid callsdocument.importNode(node, true), instantiating and upgrading<x-outer>in the maindocument. Duringnew XOuter(),this.attachShadow({ mode: "open" }).appendChild(innerTpl.content.cloneNode(true))creates<x-inner>withcustomElementRegistry === window.customElements(not yet upgraded while<x-outer>is disconnected). - When Solid inserts
<x-outer>into the detached<form>(form.appendChild(outer)),<x-outer>is adopted into the inert<template>document, clearing<x-inner>.customElementRegistrytonull. - When
<form>is later inserted intodocument.body, WebKit adopts<form>and<x-outer>back intodocument, but fails to restorecustomElementRegistryon unupgraded descendants inside<x-outer.shadowRoot>(<x-inner>.customElementRegistrystaysnullforever, so<x-inner>never upgrades).
(Note: <form><x-outer /></form> in a single JSX expression does not trigger this because the compiler merges them into _$template("<form><x-outer>", 1). Splitting <OuterField /> into a child component emits separate templates and triggers the bug.)
Possible fix
Ensure cached template prototype nodes in create() belong to document (e.g. document.adoptNode(node) when flag !== 1), so node.cloneNode(true) is already owned by document and never adopts children into an inert <template> document.
Temporary local fix
if (typeof window !== 'undefined' && 'customElementRegistry' in Element.prototype) {
const cloneNode = Element.prototype.cloneNode;
Element.prototype.cloneNode = function (deep?: boolean) {
return this.ownerDocument !== document && this.ownerDocument.defaultView === null
? document.importNode(this, deep)
: cloneNode.call(this, deep);
};
}
- Ngôn ngữ chính
- TypeScript
- Star
- 37k
- Fork
- 1.2k
- Merge trung bình
- 8 giờ 43 phút
- Pull request đã merge (30 ngày)
- 365
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[2.0.4] Nested `<Errored>`: the outer boundary stays on an error the inner one rethrew, after the next error is one the inner one handlesCó thể đã có người làm @MilindChatrabhuji đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
activepieces/activepieces#17974 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
OHDSI/Data2Evidence#3777 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
AOSSIE-Org/PictoPy#1802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Termix-SSH/Plugin-Snippets#26 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-reported bug from-app needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
nightly-labs/openbot#20504 ·
Maintainer thường phản hồi trong vòng 1 ngày