diff --git a/CHANGELOG b/CHANGELOG index bd00446..a3d6487 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* deprecation extension: mark Array#reduce() as removed. [#569 state:resolved] (Tobie Langel) + * `Form.serialize` now works safely with forms that have "length"-named elements. [#77 state:resolved] (Peter Adrianov, John-David Dalton, kangax) * `Element#update` now takes care of SCRIPT elements in IE. [#573 state:resolved] (Martin, Tobie Langel, kangax) diff --git a/ext/update_helper/prototype_update_helper.html b/ext/update_helper/prototype_update_helper.html index d2d4325..72d49a6 100644 --- a/ext/update_helper/prototype_update_helper.html +++ b/ext/update_helper/prototype_update_helper.html @@ -6,8 +6,8 @@ - - + +

Prototype Unit test file

@@ -259,6 +259,14 @@ this.assertRespondsTo('toJSON', h) }, + testArray: function() { + var a = [0, 1, 2, 3]; + + a.reduce(function(){}); + this.assertErrorNotified('Array#reduce is no longer supported.\n' + + 'This is due to an infortunate naming collision with Mozilla\'s soon to be standardized (as of EcmaScript 3.1) Array#reduce implementation (whhich is similar to Prototype\'s Array#inject).') + }, + testClass: function() { Class.create(); this.assertInfoNotified('The class API has been fully revised and now allows for mixins and inheritance.\n' + diff --git a/ext/update_helper/prototype_update_helper.js b/ext/update_helper/prototype_update_helper.js index 3cbc56a..9393ed5 100644 --- a/ext/update_helper/prototype_update_helper.js +++ b/ext/update_helper/prototype_update_helper.js @@ -253,6 +253,14 @@ var prototypeUpdateHelper = new UpdateHelper([ type: 'warn' }, + { + methodName: 'reduce', + namespace: Array.prototype, + message: 'Array#reduce is no longer supported.\n' + + 'This is due to an infortunate naming collision with Mozilla\'s soon to be standardized (as of EcmaScript 3.1) Array#reduce implementation (whhich is similar to Prototype\'s Array#inject).', + type: 'error' + }, + { methodName: 'unloadCache', namespace: Event, @@ -290,6 +298,7 @@ var prototypeUpdateHelper = new UpdateHelper([ } function defineSetters(obj, prop) { + storeProperties(obj); if (obj.__properties.include(prop)) return; obj.__properties.push(prop); obj.__defineGetter__(prop, function() { @@ -303,6 +312,7 @@ var prototypeUpdateHelper = new UpdateHelper([ } function checkProperties(hash) { + storeProperties(hash); var current = Object.keys(hash); if (current.length == hash.__properties.length) return; @@ -313,6 +323,12 @@ var prototypeUpdateHelper = new UpdateHelper([ }); } + function storeProperties(h) { + if (typeof h.__properties === 'undefined') + h.__properties = __properties.clone(); + return h; + } + Hash.prototype.set = Hash.prototype.set.wrap(function(proceed, property, value) { defineSetters(this, property); return proceed(property, value); @@ -335,7 +351,7 @@ var prototypeUpdateHelper = new UpdateHelper([ }); Hash.prototype.initialize = Hash.prototype.initialize.wrap(function(proceed, object) { - this.__properties = __properties.clone(); + storeProperties(this); for (var prop in object) defineSetters(this, prop); proceed(object); });