mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Added mergeProperties function to Object.prototype
Change-Id: I50346029a9bd8a7d2cf954b0cca011f73a6fae07
This commit is contained in:
parent
d994d1292e
commit
2ee1514552
|
@ -6,3 +6,14 @@
|
|||
if(!Array.prototype.last) Object.defineProperty(Array.prototype, 'last', {
|
||||
value: function() { return this[this.length - 1] }
|
||||
});
|
||||
|
||||
/** Good-old monkey-patching to let us merge properties of another object into this one. */
|
||||
if(!Object.prototype.mergeProperties) Object.defineProperty(Object.prototype, 'mergeProperties', {
|
||||
value: function (o) {
|
||||
var self = this;
|
||||
Object.keys(o).forEach(function(k) {
|
||||
self[k] = o[k];
|
||||
});
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue