<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>299300</bug_id>
          
          <creation_ts>2025-09-22 09:51:06 -0700</creation_ts>
          <short_desc>Calling attachShadow does not inherit host customElementRegistry as expected</short_desc>
          <delta_ts>2025-10-06 23:33:52 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>Safari 26</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Steve Orvell">steveorvell</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annevk</cc>
    
    <cc>justin</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2144895</commentid>
    <comment_count>0</comment_count>
    <who name="Steve Orvell">steveorvell</who>
    <bug_when>2025-09-22 09:51:06 -0700</bug_when>
    <thetext>When `attachShadow` is called without a registry, the shadowRoot does not inherit the host&apos;s customElementRegistry.

See reproduction: https://codepen.io/Steve-Orvell/pen/xbZGxOW?editors=1000

This expectation is based on https://dom.spec.whatwg.org/#dom-element-attachshadow

&quot;The attachShadow(init) method steps are:
Let registry be this’s custom element registry.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2144905</commentid>
    <comment_count>1</comment_count>
    <who name="Justin Fagnani">justin</who>
    <bug_when>2025-09-22 10:25:44 -0700</bug_when>
    <thetext>The spec behavior seems wrong. If the custom element isn&apos;t passing a registry to attachShadow(), then presumably it&apos;s expecting use the global registry. Using its parent scope&apos;s registry would very easily break it as that scope might be missing custom element definitions from self-registering element dependencies.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2145013</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2025-09-22 15:26:09 -0700</bug_when>
    <thetext>attachShadow isn&apos;t supposed to inherit host&apos;s customElementRegistry.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2145038</commentid>
    <comment_count>3</comment_count>
    <who name="Steve Orvell">steveorvell</who>
    <bug_when>2025-09-22 16:26:19 -0700</bug_when>
    <thetext>@Ryosuke 
1. Can you explain the linked spec text?
2. Can you explain the inconsistency between a shadowRoot on a div and on an undefined custom element candidate in the linked repro?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2148993</commentid>
    <comment_count>4</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2025-10-06 23:33:52 -0700</bug_when>
    <thetext>1. See https://github.com/whatwg/dom/issues/1407.
2. The patch for bug 300027 did capture the test for the div element inside an &quot;inert&quot; shadow root itself getting a shadow root with a custom element registry. No fix for that yet though, but it seems wrong to track it as part of this bug which started out about something else.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>