r104885 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104884‎ | r104885 | r104886 >
Date:19:08, 1 December 2011
Author:neilk
Status:deferred
Tags:
Comment:
misc fixes to pass jslint - catch default cases, make sure callbacks whose values are checked always return them, etc.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
@@ -537,6 +537,7 @@
538538 es.DocumentNode.traverseUpstream( nodeToDelete, function( node ) {
539539 if ( node.getParent().children.length === 1 ) {
540540 nodeToDelete = node.getParent();
 541+ return true;
541542 } else {
542543 return false;
543544 }
@@ -597,6 +598,7 @@
598599 }
599600 );
600601 splitable = es.DocumentView.splitRules[ elementType ].self;
 602+ return true;
601603 } );
602604 tx = this.documentView.model.prepareInsertion( selection.to, stack );
603605 this.model.transact( tx, true );
@@ -675,6 +677,9 @@
676678 var range = this.documentView.getRenderedLineRangeFromOffset( offset );
677679 to = direction === 'left' ? range.start : range.end;
678680 break;
 681+ default:
 682+ throw new Error( 'unrecognized cursor movement unit' );
 683+ break;
679684 }
680685 break;
681686 case 'up':
@@ -683,13 +688,10 @@
684689 case 'unit':
685690 var toNode = null;
686691 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;
694696 },
695697 this.documentView.getNodeFromOffset( selection.to, false ).getModel(),
696698 direction === 'up' ? true : false
@@ -720,7 +722,8 @@
721723 ).contentView.$.offset().left;
722724
723725 do {
724 - fakePosition.top += ++i * step;
 726+ i++;
 727+ fakePosition.top += i * step;
725728 if ( fakePosition.top < top ) {
726729 break;
727730 } else if (
@@ -737,8 +740,14 @@
738741 } while ( position.top === fakePosition.top );
739742 to = this.documentView.getOffsetFromRenderedPosition( fakePosition );
740743 break;
 744+ default:
 745+ throw new Error( 'unrecognized cursor movement unit' );
 746+ break;
741747 }
742 - break;
 748+ break;
 749+ default:
 750+ throw new Error( 'unrecognized cursor direction' );
 751+ break;
743752 }
744753
745754 if( direction != 'up' && direction != 'down' ) {

Status & tagging log