<?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>287158</bug_id>
          
          <creation_ts>2025-02-06 08:34:16 -0800</creation_ts>
          <short_desc>It is possible to have the same Attr node in multiple Elements with Trusted Types default policy</short_desc>
          <delta_ts>2025-02-18 12:04:39 -0800</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>Other</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/50532</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>266630</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Luke Warlow">lwarlow</reporter>
          <assigned_to name="Luke Warlow">lwarlow</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2092453</commentid>
    <comment_count>0</comment_count>
    <who name="Luke Warlow">lwarlow</who>
    <bug_when>2025-02-06 08:34:16 -0800</bug_when>
    <thetext>```
&lt;!DOCTYPE html&gt;
&lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;require-trusted-types-for &apos;script&apos;&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;h3 id=&quot;log&quot;&gt;&lt;/h3&gt; &lt;script&gt;
var attr = document.createAttribute(&quot;onclick&quot;);
attr.value = &quot;1+1;&quot;;
var gotCreateScript = false;

trustedTypes.createPolicy(&quot;default&quot;, {
  createScript: function(val) {
    if (gotCreateScript) {
      // We move the Attr node only the first time this is called.
      return val;
    }
    gotCreateScript = true;
    document.documentElement.setAttributeNode(attr);
    return val;
  },
});

document.body.setAttributeNode(attr);

document.getElementById(&quot;log&quot;).textContent =
  &quot;Does html and body element have the same Attr node in their attributes list: &quot; +
    (document.documentElement.attributes[0] === document.body.attributes[0]);
&lt;/script&gt; &lt;/body&gt; &lt;/html&gt;
```

By using trusted types callbacks it is possible to move Attr node to another element while it is still being set on the original element. Some discussion also in https://github.com/whatwg/dom/pull/1268</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2092469</commentid>
    <comment_count>1</comment_count>
    <who name="Luke Warlow">lwarlow</who>
    <bug_when>2025-02-06 09:19:58 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/40127</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2094463</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-02-13 08:35:15 -0800</bug_when>
    <thetext>&lt;rdar://problem/144789108&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095531</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-02-18 12:04:37 -0800</bug_when>
    <thetext>Committed 290543@main (4dad722e68b5): &lt;https://commits.webkit.org/290543@main&gt;

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

    </bug>

</bugzilla>