r105373 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105372‎ | r105373 | r105374 >
Date:22:45, 6 December 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Only act on selection change if it changed
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js
@@ -61,15 +61,21 @@
6262 */
6363 es.SurfaceModel.prototype.select = function( selection, isManual ) {
6464 selection.normalize();
65 -
66 - this.selection = selection;
67 -
68 - if ( isManual ) {
69 - // check if the last thing is a selection, if so, swap it.
70 - this.pushSelection( selection );
 65+ if (
 66+ // First selection
 67+ !this.selection ||
 68+ // From changed
 69+ selection.from !== this.selection.from ||
 70+ // To changed
 71+ selection.to !== this.selection.to
 72+ ) {
 73+ this.selection = selection;
 74+ if ( isManual ) {
 75+ // check if the last thing is a selection, if so, swap it.
 76+ this.pushSelection( selection );
 77+ }
 78+ this.emit( 'select', this.selection.clone() );
7179 }
72 -
73 - this.emit( 'select', this.selection.clone() );
7480 };
7581
7682 /**

Status & tagging log