Change `.forEach()` to `for ()` loop with break
authorFomafix <fomafix@googlemail.com>
Thu, 13 Sep 2018 18:38:09 +0000 (20:38 +0200)
committerFomafix <fomafix@googlemail.com>
Mon, 11 Feb 2019 17:14:59 +0000 (18:14 +0100)
commit5fc6a88e4c1d9c7562acb26ba085bc9f2d39d937
tree6fd54a9813e8a0026f1bd7525b6f752e117701d0
parent56fa42d4332cf41864e1df409cb8f05b2efc13db
Change `.forEach()` to `for ()` loop with break

Follow-up to change 1edba8029, which replaced:
  $.each( array, function ( index, value ) { ... } )
by:
  array.forEach( function ( value, index ) { ... } )

`jQuery.each` makes a break of the loop on a `return false`.
`Array.prototype.forEach` ignores the return value and there
is no way to stop or break a `forEach()` loop other than by
throwing an exception. [1]

A `$.each` with a `return false` could be replaced by
`Array.prototype.find`, but `find()` is not part of ES5. [2]

  return this.getItems().find( function ( filterItem ) {
    return filterItem.isSelected() && filterItem.isConflicted();
  } );

So a simple `for ()` loop with a `break` or a `return` is
used in these cases.

Also explicitly specify `undefined` as possible return value
in FiltersViewModel.prototype.getFirstConflictedItem.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find

Change-Id: I0af89d39ed789f49e06b25cac14ecd995ba58cbd
resources/src/jquery.tablesorter/jquery.tablesorter.js
resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js