Update vendors.

Former-commit-id: 31e8de8842ed9ea020f54ca06cdb87b1478e3b08
This commit is contained in:
John-David Dalton
2012-09-29 03:14:03 -07:00
parent 40cf5c99ef
commit a9dddb6066
4 changed files with 12 additions and 5 deletions

View File

@@ -926,6 +926,7 @@
// Simple proxy to `Backbone.history` to save a fragment into the history.
navigate: function(fragment, options) {
Backbone.history.navigate(fragment, options);
return this;
},
// Bind all defined routes to `Backbone.history`. We have to reverse the

View File

@@ -163,7 +163,10 @@ $(document).ready(function() {
});
test("lastIndexOf", function() {
var numbers = [1, 0, 1, 0, 0, 1, 0, 0, 0];
var numbers = [1, 0, 1];
equal(_.lastIndexOf(numbers, 1), 2);
numbers = [1, 0, 1, 0, 0, 1, 0, 0, 0];
numbers.lastIndexOf = null;
equal(_.lastIndexOf(numbers, 1), 5, 'can compute lastIndexOf, even without the native function');
equal(_.lastIndexOf(numbers, 0), 8, 'lastIndexOf the other element');

File diff suppressed because one or more lines are too long

View File

@@ -515,9 +515,12 @@
};
// Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
_.lastIndexOf = function(array, item, fromIndex) {
if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item, fromIndex);
var i = (fromIndex != null ? fromIndex : array.length);
_.lastIndexOf = function(array, item, from) {
var hasIndex = from != null;
if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
}
var i = (hasIndex ? from : array.length);
while (i--) if (array[i] === item) return i;
return -1;
};