<?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>240563</bug_id>
          
          <creation_ts>2022-05-18 00:18:50 -0700</creation_ts>
          <short_desc>Reflection for FrozenArray&lt;Element&gt; caching invariant</short_desc>
          <delta_ts>2022-06-02 14:45:56 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/34194</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>196843</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Manuel Rego Casasnovas">rego</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1869932</commentid>
    <comment_count>0</comment_count>
    <who name="Manuel Rego Casasnovas">rego</who>
    <bug_when>2022-05-18 00:18:50 -0700</bug_when>
    <thetext>In bug #239853 we implemented reflection for FrozenArray&lt;Element&gt; attributes following the spec text at:
https://github.com/whatwg/html/pull/3917

However the implementation doesn&apos;t match one of the things in the spec:
&gt; This extra caching layer is necessary to preserve the invariant that element.reflectedElements === element.reflectedElements.

We don&apos;t have an extra caching layer so we can return the very same array in this case. The contents of the arrays are the same but the previous condition is false.

I&apos;m not really sure how we could implemented that, as we&apos;re storing the &quot;explicitly set attr-elements&quot; using &quot;HashMap&lt;QualifiedName, Vector&lt;WeakPtr&lt;Element&gt;&gt;&gt;&quot; but Element::getElementsArrayAttribute() returns &quot;Vector&lt;RefPtr&lt;Element&gt;&gt;&quot;. I&apos;m not sure if we can cache the latter somehow without causing memory leaks.

Domenic suggested that ObservableArray could fix this issue (see https://github.com/web-platform-tests/wpt/pull/34095#discussion_r875333836), but we don&apos;t have support yet (bug #238281).

Any advice about how we can solve this issue? Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1870503</commentid>
    <comment_count>1</comment_count>
    <who name="Manuel Rego Casasnovas">rego</who>
    <bug_when>2022-05-19 12:40:35 -0700</bug_when>
    <thetext>cdumez@ suggested to use JSValueInWrappedObject to fix this issue. I&apos;ll give that a try. Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871664</commentid>
    <comment_count>2</comment_count>
    <who name="Manuel Rego Casasnovas">rego</who>
    <bug_when>2022-05-24 22:52:38 -0700</bug_when>
    <thetext>Pull request with the patch: https://github.com/WebKit/WebKit/pull/974</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871675</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-05-25 00:19:13 -0700</bug_when>
    <thetext>&lt;rdar://problem/93884533&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1873699</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-06-02 14:45:53 -0700</bug_when>
    <thetext>Committed r295148 (251237@main): &lt;https://commits.webkit.org/251237@main&gt;

Reviewed commits have been landed. Closing PR #1166 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>