|
|
@@ -38,16 +38,19 @@ export default function modifySelection( selection, options = {} ) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // Replace TreeWalker step wrapper by clean step value.
|
|
|
+ next = next.value;
|
|
|
+
|
|
|
// 2. Consume next character.
|
|
|
- if ( next.value.type == 'CHARACTER' ) {
|
|
|
- selection.setFocus( next.value.nextPosition );
|
|
|
+ if ( next.type == 'CHARACTER' ) {
|
|
|
+ selection.setFocus( next.nextPosition );
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 3. We're entering an element, so let's consume it fully.
|
|
|
- if ( next.value.type == ( isForward ? 'ELEMENT_START' : 'ELEMENT_END' ) ) {
|
|
|
- selection.setFocus( next.value.item, isForward ? 'AFTER' : 'BEFORE' );
|
|
|
+ if ( next.type == ( isForward ? 'ELEMENT_START' : 'ELEMENT_END' ) ) {
|
|
|
+ selection.setFocus( next.item, isForward ? 'AFTER' : 'BEFORE' );
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
@@ -60,14 +63,17 @@ export default function modifySelection( selection, options = {} ) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // Replace TreeWalker step wrapper by clean step value.
|
|
|
+ next = next.value;
|
|
|
+
|
|
|
// 4.2. Character found after element end. Not really a valid case in our data model, but let's
|
|
|
// do something sensible and put the selection focus before that character.
|
|
|
- if ( next.value.type == 'CHARACTER' ) {
|
|
|
- selection.setFocus( next.value.previousPosition );
|
|
|
+ if ( next.type == 'CHARACTER' ) {
|
|
|
+ selection.setFocus( next.previousPosition );
|
|
|
}
|
|
|
// 4.3. OK, we're entering a new element. So let's place there the focus.
|
|
|
else {
|
|
|
- selection.setFocus( next.value.item, isForward ? 0 : 'END' );
|
|
|
+ selection.setFocus( next.item, isForward ? 0 : 'END' );
|
|
|
}
|
|
|
}
|
|
|
|