r103184 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103183‎ | r103184 | r103185 >
Date:16:21, 15 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
Fix IE-specific test breakages. Two tests were broken because Array.prototype.indexOf() was used, another one because Array.prototype.splice() is broken in IE:

>>[1,2,3].slice(0).length
3
>>[1,2,3].slice(0, undefined).length
0
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/bases/es.EventEmitter.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js
@@ -474,7 +474,8 @@
475475 start = Math.max( 0, Math.min( this.data.length, range.start ) );
476476 end = Math.max( 0, Math.min( this.data.length, range.end ) );
477477 }
478 - var data = this.data.slice( start, end );
 478+ // Work around IE bug: arr.slice( 0, undefined ) returns [] while arr.slice( 0 ) behaves correctly
 479+ var data = end === undefined ? this.data.slice( start ) : this.data.slice( start, end );
479480 return deep ? es.copyArray( data ) : data;
480481 };
481482
Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js
@@ -209,7 +209,7 @@
210210 * @returns {Integer} Index of child node or -1 if node was not found
211211 */
212212 es.DocumentModelBranchNode.prototype.indexOf = function( node ) {
213 - return this.children.indexOf( node );
 213+ return es.arrayIndexOf( this.children, node );
214214 };
215215
216216 /**
Index: trunk/extensions/VisualEditor/modules/es/bases/es.EventEmitter.js
@@ -148,7 +148,7 @@
149149 if ( handlers.length === 1 && handlers[0] === listener ) {
150150 delete this.events[type];
151151 } else {
152 - var i = handlers.indexOf( listener );
 152+ var i = es.arrayIndexOf( handlers, listener );
153153 if ( i < 0 ) {
154154 return this;
155155 }

Status & tagging log