Skip to content

Commit c8a6942

Browse files
Merge branch 'master' of github.com:sstephenson/prototype
2 parents 6deb049 + e9ce0d2 commit c8a6942

File tree

8 files changed

+29
-13
lines changed

8 files changed

+29
-13
lines changed

src/prototype/ajax/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* status-specific callback is defined, it gets invoked. Otherwise, if
5050
* `onSuccess` is defined and the response is deemed a success (see below), it
5151
* is invoked. Otherwise, if `onFailure` is defined and the response is *not*
52-
* deemed a sucess, it is invoked. Only after that potential first callback is
52+
* deemed a success, it is invoked. Only after that potential first callback is
5353
* `onComplete` called.
5454
*
5555
* ##### A note on portability

src/prototype/dom/event.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@
260260
* its ancestor chain. If `expression` is not given, the element which fired
261261
* the event is returned.
262262
*
263-
* *If no matching element is found, the document itself (`HTMLDocument` node)
264-
* is returned.*
263+
* *If no matching element is found, `undefined` is returned.*
265264
*
266265
* ##### Example
267266
*

src/prototype/lang/array.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -647,16 +647,15 @@ Array.from = $A;
647647
}
648648

649649
/**
650-
* Array#some([iterator = Prototype.K[, context]]) -> Array
650+
* Array#some([iterator = Prototype.K[, context]]) -> Boolean
651651
* - iterator (Function): An optional function to use to evaluate each
652652
* element in the enumeration; the function should return the value to
653653
* test. If this is not provided, the element itself is tested.
654654
* - context (Object): An optional object to use as `this` within
655655
* calls to the iterator.
656656
*
657-
* Returns the result of applying `iterator` to each item in the array. If
658-
* no iterator is provided, the elements are simply copied to the returned
659-
* array.
657+
* Determines whether at least one element is truthy (boolean-equivalent to
658+
* `true`), either directly or through computation by the provided iterator.
660659
*
661660
* `Array#some` acts as an ECMAScript 5 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
662661
* It is only defined if not already present in the user's browser, and it
@@ -692,7 +691,7 @@ Array.from = $A;
692691
* - context (Object): An optional object to use as `this` within
693692
* calls to the iterator.
694693
*
695-
* Determines whether at least one element is truthy (boolean-equivalent to
694+
* Determines whether all elements are truthy (boolean-equivalent to
696695
* `true`), either directly or through computation by the provided iterator.
697696
*
698697
* `Array#every` acts as an ECMAScript 5 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).

src/prototype/lang/function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Object.extend(Function.prototype, (function() {
123123
var __method = this, args = slice.call(arguments, 1);
124124

125125
var bound = function() {
126-
var a = merge(args, arguments), c = context;
126+
var a = merge(args, arguments);
127127
// Ignore the supplied context when the bound function is called with
128128
// the "new" keyword.
129129
var c = this instanceof bound ? this : context;

src/prototype/lang/hash.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ var Hash = Class.create(Enumerable, (function() {
9494

9595
// Our _internal_ each
9696
function _each(iterator, context) {
97+
var i = 0;
9798
for (var key in this._object) {
9899
var value = this._object[key], pair = [key, value];
99100
pair.key = key;
100101
pair.value = value;
101-
iterator.call(context, pair);
102+
iterator.call(context, pair, i);
103+
i++;
102104
}
103105
}
104106

src/prototype/lang/range.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ var ObjectRange = Class.create(Enumerable, (function() {
108108
}
109109

110110
function _each(iterator, context) {
111-
var value = this.start;
112-
while (this.include(value)) {
113-
iterator.call(context, value);
111+
var value = this.start, i;
112+
for (i = 0; this.include(value); i++) {
113+
iterator.call(context, value, i);
114114
value = value.succ();
115115
}
116116
}

test/unit/hash_test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ new Test.Unit.Runner({
182182
var foo = new FooMaker('bar');
183183
this.assertEqual("key=bar", new Hash(foo).toQueryString());
184184
this.assertEqual("key=bar", new Hash(new Hash(foo)).toQueryString());
185+
},
186+
187+
testIterationWithEach: function() {
188+
var h = $H({a:1, b:2});
189+
var result = []
190+
h.each(function(kv, i){
191+
result.push(i);
192+
});
193+
this.assertEnumEqual([0,1], result);
185194
}
186195

187196
});

test/unit/range_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ new Test.Unit.Runner({
2727
});
2828

2929
this.assertEnumEqual([0, 1, 2, 3], results);
30+
31+
results = [];
32+
$R(2, 4, true).each(function(value, index) {
33+
results.push(index);
34+
});
35+
this.assertEnumEqual([0, 1], results);
36+
3037
},
3138

3239
testAny: function() {

0 commit comments

Comments
 (0)