<?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>301858</bug_id>
          
          <creation_ts>2025-11-03 04:37:57 -0800</creation_ts>
          <short_desc>Update &lt;option&gt; when descendants change</short_desc>
          <delta_ts>2025-11-10 04:38:11 -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>Forms</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=301859</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>286642</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Anne van Kesteren">annevk</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2155956</commentid>
    <comment_count>0</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2025-11-03 04:37:57 -0800</bug_when>
    <thetext>We currently update the &lt;option&gt; element when its immediate children change, but to be fully correct we need to update it when descendants change. See this demo which requires HTMLEnhancedSelectParsingEnabled and should show &quot;24&quot; after clicking:

&lt;p&gt;&lt;select id=select&gt;
 &lt;div&gt;
  &lt;option&gt;2&lt;div id=evil&gt;3&lt;/div&gt;&lt;/option&gt;
 &lt;/div&gt;
 &lt;div&gt;
  &lt;option&gt;1&lt;/option&gt;
 &lt;/div&gt;
&lt;/select&gt;
&lt;p&gt;&lt;button onclick=evil.textContent=&apos;4&apos;&gt;Click&lt;/button&gt;

This is not a critical issue, but would be nice to do correctly. Here&apos;s a sketch from rniwa on how to approach this:

&gt; I think we want to add a new Node flag to identify any descendent of option. Something like StateFlag::HasOptionAsAncestor. Then we want to propagate this flag in insertedIntoAncestor and removedFromAncestor. See Element::updateEffectiveTextDirectionIfNeeded() for an example. Once this flag is properly updated, we want to add a [[unlikely]] if statement which notifies option in Element::childrenChanged.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2157621</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-11-10 04:38:11 -0800</bug_when>
    <thetext>&lt;rdar://problem/164396354&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>