mw.Map: add ability to map over an existing object other than 'window'
authorOri Livneh <ori@wikimedia.org>
Mon, 28 Oct 2013 22:58:02 +0000 (15:58 -0700)
committerOri Livneh <ori@wikimedia.org>
Mon, 28 Oct 2013 23:22:50 +0000 (16:22 -0700)
commit63f8d7b9e5d4946dfe8a3f2564a9f1db25e28755
tree444c3354d7a144ca4a667860329a4bc33fea693a
parent7f51cf22f918089a0c9669a60c9c3fb92bbd16b8
mw.Map: add ability to map over an existing object other than 'window'

I don't love the fact that mw.Map features so prominently in mediawiki.js, but
since it's there to stay it might as well be useful for a wider range of use
cases. This patch makes it possible to pass an existing value-bearing object to
be mapped over to the Map constructor.

The effect is the same as constructing the object and then overriding its
'values' attribute. But doing that feels like you're sneaking around the back
to hack the API. Making it part of the official API makes it OK to do.

Change-Id: Id9f8d9569de8889fc3ffa24a6e7f4afca1aeabee
resources/mediawiki/mediawiki.js
tests/qunit/suites/resources/mediawiki/mediawiki.test.js