PleaseStand has uploaded a new change for review.

Change subject: Add 'safe' option and .each() function to mw.Map()
......................................................................

Add 'safe' option and .each() function to mw.Map()

I recently encountered a bug in the ApiSandbox extension stemming from
the use of objects as associative arrays. ApiSandbox does not use the
mw.Map() constructor; however, I did notice that mw.Map() fails when
faced with string keys such as 'toString', 'watch', and '__proto__'.

The only clean, reliable way I have found to handle all special cases
is to prefix all keys with a string that is not a lowercase letter and
not an underscore. I chose the dollar sign ($) for brevity.

The .each() function is included so that all associative array operations
possible with plain objects are now possible with Maps without resorting
to direct access to .values. This is desirable because the prefixing of
keys is an implementation detail that might change.

To not risk breaking backward compatibility, this commit does not
change existing code to use the 'safe' option.

Change-Id: Ic8e7f4d3044f2c372651d3ee997b1bfa6bdd7334
---
M RELEASE-NOTES-1.21
M resources/mediawiki/mediawiki.js
M tests/qunit/suites/resources/mediawiki/mediawiki.test.js
3 files changed, 111 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/81/40081/1
--
To view, visit https://gerrit.wikimedia.org/r/40081
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8e7f4d3044f2c372651d3ee997b1bfa6bdd7334
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to