File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 215
215
216
216
function moveNativeSelectionToBookmark ( document , bm ) {
217
217
var sel = document . getSelection ( ) ,
218
- range = document . createRange ( ) ;
218
+ range = document . createRange ( ) ,
219
+ wasZWS = ( bm [ 0 ] . node . textContent == '\u200B' ) ;
219
220
220
221
range . setStart ( bm [ 0 ] . node , bm [ 0 ] . offset ) ;
221
222
range . collapse ( true ) ;
222
223
sel . removeAllRanges ( ) ;
223
224
sel . addRange ( range ) ;
225
+
226
+ // For some unknown reason, Selection::addRange clears text node content
227
+ // if the only character in the content was ZWS. So to prevent
228
+ // errors, we recreate that. (#13284, #13389, #13307)
229
+ if ( wasZWS && ( bm [ 0 ] . node == bm [ 1 ] . node ) && bm [ 0 ] . node . textContent . length === 0 )
230
+ bm [ 1 ] . node . textContent = '\u200B' ;
231
+
224
232
sel . extend ( bm [ 1 ] . node , bm [ 1 ] . offset ) ;
225
233
}
226
234
You can’t perform that action at this time.
0 commit comments