<?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>230594</bug_id>
          
          <creation_ts>2021-09-21 21:14:28 -0700</creation_ts>
          <short_desc>Invalid browser selection after splitting a text node</short_desc>
          <delta_ts>2026-01-05 10:51:43 -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>Safari 14</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>macOS 10.15</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="James Toohey">james</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>darin</cc>
    
    <cc>rniwa</cc>
    
    <cc>thespyder</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1795940</commentid>
    <comment_count>0</comment_count>
      <attachid>438917</attachid>
    <who name="James Toohey">james</who>
    <bug_when>2021-09-21 21:14:28 -0700</bug_when>
    <thetext>Created attachment 438917
Replication HTML file

Hi team,

As per the spec, when splitting a text node, any live ranges that start or end in the node being split must have their respective nodes and offsets modified. 

https://dom.spec.whatwg.org/#concept-text-split (Important: Section 7)

In Safari 14 (and also in the newly released Safari 15 &amp; Tech Preview), splitting a text node does not correctly adjust the selection to account for this:
- The offsets are not adjusted
- The nodes are not changed when appropriate

Please see the attached HTML file for a replication case. This works correctly in Firefox 92 and Chrome 93.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1797924</commentid>
    <comment_count>1</comment_count>
    <who name="Sam Sneddon [:gsnedders]">gsnedders</who>
    <bug_when>2021-09-28 09:43:05 -0700</bug_when>
    <thetext>I kinda suspect this might be fixed by bug 220514 (live ranges in selection)? Though at least currently it appears regressed by live ranges in selection (even the initial selection is wrong).

Marking this is blocking, then others can debate whether that&apos;s fair. ;P</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1798175</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-09-28 21:15:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/83655114&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1920208</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-12-17 02:11:30 -0800</bug_when>
    <thetext>Enabling live range selection doesn&apos;t fix this bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>438917</attachid>
            <date>2021-09-21 21:14:28 -0700</date>
            <delta_ts>2021-09-21 21:14:28 -0700</delta_ts>
            <desc>Replication HTML file</desc>
            <filename>selection-after-text-node-split.html</filename>
            <type>text/html</type>
            <size>785</size>
            <attacher name="James Toohey">james</attacher>
            
              <data encoding="base64">PHA+MS4gT3BlbiB0aGUgZGV2ZWxvcGVyIGNvbnNvbGUuPC9wPgoKPHA+Mi4gU2VsZWN0ICJ3b3Jk
MiIgYmVsb3cgYW5kIGNsaWNrICJMb2cgU2VsZWN0aW9uIi48L3A+Cgo8cCBpZD0icDEiPndvcmQx
IHdvcmQyIHdvcmQzPC9wPgoKPHA+My4gQ2xpY2sgIlNwbGl0IHRleHQgbm9kZSIgYW5kIHRoZW4g
Y2xpY2sgIkxvZyBTZWxlY3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