prototypejs / prototype

Prototype JavaScript framework
http://prototypejs.org/
Other
3.53k stars 639 forks source link

Element.replace() swaps element and textNode if used inside a table #357

Open Chris78 opened 1 year ago

Chris78 commented 1 year ago

Consider the following table:

<table>
  <tr>
    <td>
       <span id='elm'>X</span> some text
    </td>
   </tr>
</table>

and apply the following javascript code to it:

Element.replace('elm', '<span>Y</span>')

Expected result: The table cell should change from X some text to Y some text

Actual result: By replacing the span it gets swapped with the textNode "some text". So the table cell reads: some text Y

This will not happen though, if the span 'elm' is followed by an html tag (<span>, <b> or whatever).