Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -537,6 +537,7 @@ |
538 | 538 | es.DocumentNode.traverseUpstream( nodeToDelete, function( node ) { |
539 | 539 | if ( node.getParent().children.length === 1 ) { |
540 | 540 | nodeToDelete = node.getParent(); |
| 541 | + return true; |
541 | 542 | } else { |
542 | 543 | return false; |
543 | 544 | } |
— | — | @@ -597,6 +598,7 @@ |
598 | 599 | } |
599 | 600 | ); |
600 | 601 | splitable = es.DocumentView.splitRules[ elementType ].self; |
| 602 | + return true; |
601 | 603 | } ); |
602 | 604 | tx = this.documentView.model.prepareInsertion( selection.to, stack ); |
603 | 605 | this.model.transact( tx, true ); |
— | — | @@ -675,6 +677,9 @@ |
676 | 678 | var range = this.documentView.getRenderedLineRangeFromOffset( offset ); |
677 | 679 | to = direction === 'left' ? range.start : range.end; |
678 | 680 | break; |
| 681 | + default: |
| 682 | + throw new Error( 'unrecognized cursor movement unit' ); |
| 683 | + break; |
679 | 684 | } |
680 | 685 | break; |
681 | 686 | case 'up': |
— | — | @@ -683,13 +688,10 @@ |
684 | 689 | case 'unit': |
685 | 690 | var toNode = null; |
686 | 691 | this.model.getDocument().traverseLeafNodes( |
687 | | - function( node ) { |
688 | | - if ( toNode === null) { |
689 | | - toNode = node; |
690 | | - } else { |
691 | | - toNode = node; |
692 | | - return false; |
693 | | - } |
| 692 | + function( node ) { |
| 693 | + var doNextChild = toNode === null; |
| 694 | + toNode = node; |
| 695 | + return doNextChild; |
694 | 696 | }, |
695 | 697 | this.documentView.getNodeFromOffset( selection.to, false ).getModel(), |
696 | 698 | direction === 'up' ? true : false |
— | — | @@ -720,7 +722,8 @@ |
721 | 723 | ).contentView.$.offset().left; |
722 | 724 | |
723 | 725 | do { |
724 | | - fakePosition.top += ++i * step; |
| 726 | + i++; |
| 727 | + fakePosition.top += i * step; |
725 | 728 | if ( fakePosition.top < top ) { |
726 | 729 | break; |
727 | 730 | } else if ( |
— | — | @@ -737,8 +740,14 @@ |
738 | 741 | } while ( position.top === fakePosition.top ); |
739 | 742 | to = this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
740 | 743 | break; |
| 744 | + default: |
| 745 | + throw new Error( 'unrecognized cursor movement unit' ); |
| 746 | + break; |
741 | 747 | } |
742 | | - break; |
| 748 | + break; |
| 749 | + default: |
| 750 | + throw new Error( 'unrecognized cursor direction' ); |
| 751 | + break; |
743 | 752 | } |
744 | 753 | |
745 | 754 | if( direction != 'up' && direction != 'down' ) { |