Remove hasOwnProperty checks in for-loops
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 6 Jul 2018 02:46:56 +0000 (19:46 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 6 Jul 2018 02:46:56 +0000 (19:46 -0700)
commitc22666dfaa4d5ff5a8eff4835c37597f4d88e786
tree963ff590d4788f174a1afa27825ab7b84ec1d501
parent70fe08d2df8240ee01e8eb3d692efc2a61570c15
Remove hasOwnProperty checks in for-loops

There are some good uses of hasOwnProperty checks, but in for-loops
they only make sense if the object in question is not a plain
object (eg. class instance) and the code in question is explicitly
interested in instance properties. This is rare, but one example
exists in mediawiki.Uri, where it clones an instance by copying
properties from another instance.

Anywhere a plain object is looped over, the check is redundant
because Object.prototype has no enumerable own properties.

Both jQuery and ResourceLoader do not support environments
that alter Object.prototype to be that way, and the majority
of our for-loops actually already didn't have this check.

This commit removes the few hasOwnProperty checks that still
existed on for-loops over plain objects.

Side-note: jQuery.each() does an unfiltered for-loop, which means
           it too does not perform hasOwnProperty checks.

Change-Id: Ib5e5a04a5a8e21ab62b4e779117077ea5b0f8a47
resources/src/jquery.tablesorter/jquery.tablesorter.js
resources/src/mediawiki.api/upload.js
resources/src/mediawiki.debug/debug.js
resources/src/mediawiki.language/mediawiki.language.numbers.js
resources/src/mediawiki.page.watch.ajax.js