Skip to content

Commit ce84cc4

Browse files
committed
Added internal wrapper function.
1 parent f320045 commit ce84cc4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

core/selection.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,18 @@
192192
];
193193
}
194194

195+
function setRangeOnSelection( range, selection ) {
196+
selection.removeAllRanges();
197+
selection.addRange( range );
198+
}
199+
195200
function moveNativeSelectionToBookmark( document, bm ) {
196201
var sel = document.getSelection(),
197202
range = document.createRange();
198203

199204
range.setStart( bm[ 0 ].node, bm[ 0 ].offset );
200205
range.collapse( true );
201-
sel.removeAllRanges();
202-
sel.addRange( range );
206+
setRangeOnSelection( range, sel );
203207
sel.extend( bm[ 1 ].node, bm[ 1 ].offset );
204208
}
205209

@@ -221,8 +225,7 @@
221225
nativeRange.setStart( range.startContainer.$, range.startOffset );
222226
nativeRange.collapse( 1 );
223227

224-
nativeSel.removeAllRanges();
225-
nativeSel.addRange( nativeRange );
228+
setRangeOnSelection( nativeRange, nativeSel );
226229
}
227230
else {
228231
// IE in specific case may also fire selectionchange.
@@ -1978,8 +1981,7 @@
19781981
}
19791982

19801983
// Select the range.
1981-
sel.removeAllRanges();
1982-
sel.addRange( nativeRange );
1984+
setRangeOnSelection( nativeRange, sel );
19831985
}
19841986
}
19851987

0 commit comments

Comments
 (0)