Skip to content

Commit 5c21913

Browse files
committed
Merge branch 'master' into gh-pages
2 parents d4e667e + 834acb6 commit 5c21913

File tree

9 files changed

+219
-332
lines changed

9 files changed

+219
-332
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "underscore",
3-
"version": "1.8.0",
3+
"version": "1.8.1",
44
"main": "underscore.js",
55
"keywords": ["util", "functional", "server", "client", "browser"],
66
"ignore" : ["docs", "test", "*.yml", "CNAME", "index.html", "favicon.ico", "CONTRIBUTING.md"]

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"repo" : "jashkenas/underscore",
66
"main" : "underscore.js",
77
"scripts" : ["underscore.js"],
8-
"version" : "1.8.0",
8+
"version" : "1.8.1",
99
"license" : "MIT"
1010
}

docs/underscore.html

Lines changed: 186 additions & 242 deletions
Large diffs are not rendered by default.

index.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
<div id="sidebar" class="interface">
181181

182182
<a class="toc_title" href="#">
183-
Underscore.js <span class="version">(1.8.0)</span>
183+
Underscore.js <span class="version">(1.8.1)</span>
184184
</a>
185185
<ul class="toc_section">
186186
<li>&raquo; <a href="https://github.com/jashkenas/underscore">GitHub Repository</a></li>
@@ -403,13 +403,13 @@ <h2>Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and u
403403

404404
<table style="min-width: 640px;">
405405
<tr>
406-
<td><a href="underscore.js">Development Version (1.8.0)</a></td>
407-
<td><i>51kb, Uncompressed with Plentiful Comments</i></td>
406+
<td><a href="underscore.js">Development Version (1.8.1)</a></td>
407+
<td><i>49kb, Uncompressed with Plentiful Comments</i></td>
408408
</tr>
409409
<tr>
410-
<td><a href="underscore-min.js">Production Version (1.8.0)</a></td>
410+
<td><a href="underscore-min.js">Production Version (1.8.1)</a></td>
411411
<td>
412-
<i>5.7kb, Minified and Gzipped <b>(3x smaller than Lodash ;)</b></i>
412+
<i>5.4kb, Minified and Gzipped <b>(3x smaller than Lodash ;)</b></i>
413413
&nbsp;<small>(<a href="underscore-min.map">Source Map</a>)</small>
414414
</td>
415415
</tr>
@@ -2191,6 +2191,17 @@ <h2 id="links">Links &amp; Suggested Reading</h2>
21912191

21922192
<h2 id="changelog">Change Log</h2>
21932193

2194+
<p id="1.8.1">
2195+
<b class="header">1.8.1</b> &mdash; <small><i>Feb. 19, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.8.0...1.8.1">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.8.1/index.html">Docs</a><br />
2196+
<ul>
2197+
<li>
2198+
Fixes/changes some old-Internet-Explorer and related edge case
2199+
behavior. Test your app with Underscore 1.8.1 in an old IE and let
2200+
us know how its doing...
2201+
</li>
2202+
</ul>
2203+
</p>
2204+
21942205
<p id="1.8.0">
21952206
<b class="header">1.8.0</b> &mdash; <small><i>Feb. 19, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.7.0...1.8.0">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.8.0/index.html">Docs</a><br />
21962207
<ul>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"url": "git://github.com/jashkenas/underscore.git"
1616
},
1717
"main": "underscore.js",
18-
"version": "1.8.0",
18+
"version": "1.8.1",
1919
"devDependencies": {
2020
"docco": "0.6.x",
2121
"eslint": "0.6.x",

test/objects.js

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,6 @@
1515
deepEqual(_.keys(1), []);
1616
deepEqual(_.keys('a'), []);
1717
deepEqual(_.keys(true), []);
18-
19-
// keys that may be missed if the implementation isn't careful
20-
var trouble = {
21-
'constructor': Object,
22-
'valueOf': _.noop,
23-
'hasOwnProperty': null,
24-
'toString': 5,
25-
'toLocaleString': undefined,
26-
'propertyIsEnumerable': /a/,
27-
'isPrototypeOf': this,
28-
'__defineGetter__': Boolean,
29-
'__defineSetter__': {},
30-
'__lookupSetter__': false,
31-
'__lookupGetter__': []
32-
};
33-
var troubleKeys = ['constructor', 'valueOf', 'hasOwnProperty', 'toString', 'toLocaleString', 'propertyIsEnumerable',
34-
'isPrototypeOf', '__defineGetter__', '__defineSetter__', '__lookupSetter__', '__lookupGetter__'].sort();
35-
deepEqual(_.keys(trouble).sort(), troubleKeys, 'matches non-enumerable properties');
3618
});
3719

3820
test('allKeys', function() {
@@ -48,25 +30,11 @@
4830
deepEqual(_.allKeys(val), []);
4931
});
5032

51-
// allKeys that may be missed if the implementation isn't careful
52-
var trouble = {
53-
constructor: Object,
54-
valueOf: _.noop,
55-
hasOwnProperty: null,
56-
toString: 5,
57-
toLocaleString: undefined,
58-
propertyIsEnumerable: /a/,
59-
isPrototypeOf: this
60-
};
61-
var troubleKeys = ['constructor', 'valueOf', 'hasOwnProperty', 'toString', 'toLocaleString', 'propertyIsEnumerable',
62-
'isPrototypeOf'].sort();
63-
deepEqual(_.allKeys(trouble).sort(), troubleKeys, 'matches non-enumerable properties');
64-
6533
function A() {}
6634
A.prototype.foo = 'foo';
6735
var b = new A();
6836
b.bar = 'bar';
69-
deepEqual(_.allKeys(b), ['bar', 'foo'], 'should include inherited keys');
37+
deepEqual(_.allKeys(b).sort(), ['bar', 'foo'], 'should include inherited keys');
7038

7139
function y() {}
7240
y.x = 'z';
@@ -543,10 +511,6 @@
543511
var args = function(){ return arguments; };
544512
ok(_.isEmpty(args()), 'empty arguments object is empty');
545513
ok(!_.isEmpty(args('')), 'non-empty arguments object is not empty');
546-
547-
// covers collecting non-enumerable properties in IE < 9
548-
var nonEnumProp = {'toString': 5};
549-
ok(!_.isEmpty(nonEnumProp), 'non-enumerable property is not empty');
550514
});
551515

552516
if (typeof document === 'object') {
@@ -772,10 +736,6 @@
772736

773737
Prototest.x = 5;
774738
ok(_.isMatch({x: 5, y: 1}, Prototest), 'spec can be a function');
775-
776-
//null edge cases
777-
var oCon = {'constructor': Object};
778-
deepEqual(_.map([null, undefined, 5, {}], _.partial(_.isMatch, _, oCon)), [false, false, false, true], 'doesnt fasley match constructor on undefined/null');
779739
});
780740

781741
test('matcher', function() {
@@ -828,11 +788,6 @@
828788
o.b = 2;
829789
o.a = 1;
830790
equal(m({'b': 1}), true, 'changing spec object doesnt change matches result');
831-
832-
833-
//null edge cases
834-
var oCon = _.matcher({'constructor': Object});
835-
deepEqual(_.map([null, undefined, 5, {}], oCon), [false, false, false, true], 'doesnt fasley match constructor on undefined/null');
836791
});
837792

838793
test('matcher', function() {
@@ -885,11 +840,6 @@
885840
o.b = 2;
886841
o.a = 1;
887842
equal(m({'b': 1}), true, 'changing spec object doesnt change matches result');
888-
889-
890-
//null edge cases
891-
var oCon = _.matcher({'constructor': Object});
892-
deepEqual(_.map([null, undefined, 5, {}], oCon), [false, false, false, true], 'doesnt fasley match constructor on undefined/null');
893843
});
894844

895845
test('findKey', function() {

underscore-min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

underscore-min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

underscore.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Underscore.js 1.8.0
1+
// Underscore.js 1.8.1
22
// http://underscorejs.org
33
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
44
// Underscore may be freely distributed under the MIT license.
@@ -32,7 +32,7 @@
3232
nativeBind = FuncProto.bind,
3333
nativeCreate = Object.create;
3434

35-
// Reusable constructor function for prototype setting.
35+
// Naked function reference for surrogate-prototype-swapping.
3636
var Ctor = function(){};
3737

3838
// Create a safe reference to the Underscore object for use below.
@@ -55,7 +55,7 @@
5555
}
5656

5757
// Current version.
58-
_.VERSION = '1.8.0';
58+
_.VERSION = '1.8.1';
5959

6060
// Internal function that returns an efficient (for current engines) version
6161
// of the passed-in callback, to be repeatedly applied in other Underscore
@@ -705,17 +705,18 @@
705705
if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
706706
if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
707707
var args = slice.call(arguments, 2);
708-
return function bound() {
708+
var bound = function() {
709709
return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
710710
};
711+
return bound;
711712
};
712713

713714
// Partially apply a function by creating a version that has had some of its
714715
// arguments pre-filled, without changing its dynamic `this` context. _ acts
715716
// as a placeholder, allowing any combination of arguments to be pre-filled.
716717
_.partial = function(func) {
717718
var boundArgs = slice.call(arguments, 1);
718-
return function bound() {
719+
var bound = function() {
719720
var position = 0, length = boundArgs.length;
720721
var args = Array(length);
721722
for (var i = 0; i < length; i++) {
@@ -724,6 +725,7 @@
724725
while (position < arguments.length) args.push(arguments[position++]);
725726
return executeBound(func, bound, this, this, args);
726727
};
728+
return bound;
727729
};
728730

729731
// Bind a number of an object's methods to that object. Remaining arguments
@@ -892,33 +894,13 @@
892894
// Object Functions
893895
// ----------------
894896

895-
// Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
896-
var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
897-
var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString',
898-
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
899-
900-
function collectNonEnumProps(obj, keys) {
901-
var nonEnumIdx = nonEnumerableProps.length;
902-
var proto = typeof obj.constructor === 'function' ? FuncProto : ObjProto;
903-
904-
while (nonEnumIdx--) {
905-
var prop = nonEnumerableProps[nonEnumIdx];
906-
if (prop === 'constructor' ? _.has(obj, prop) : prop in obj &&
907-
obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
908-
keys.push(prop);
909-
}
910-
}
911-
}
912-
913897
// Retrieve the names of an object's own properties.
914898
// Delegates to **ECMAScript 5**'s native `Object.keys`
915899
_.keys = function(obj) {
916900
if (!_.isObject(obj)) return [];
917901
if (nativeKeys) return nativeKeys(obj);
918902
var keys = [];
919903
for (var key in obj) if (_.has(obj, key)) keys.push(key);
920-
// Ahem, IE < 9.
921-
if (hasEnumBug) collectNonEnumProps(obj, keys);
922904
return keys;
923905
};
924906

@@ -927,8 +909,6 @@
927909
if (!_.isObject(obj)) return [];
928910
var keys = [];
929911
for (var key in obj) keys.push(key);
930-
// Ahem, IE < 9.
931-
if (hasEnumBug) collectNonEnumProps(obj, keys);
932912
return keys;
933913
};
934914

@@ -1012,7 +992,9 @@
1012992
if (obj == null) return result;
1013993
if (_.isFunction(iteratee)) {
1014994
iteratee = optimizeCb(iteratee, context);
1015-
for (key in obj) {
995+
var keys = _.allKeys(obj);
996+
for (var i = 0; i < keys.length; i++) {
997+
var key = keys[i];
1016998
var value = obj[key];
1017999
if (iteratee(value, key, obj)) result[key] = value;
10181000
}

0 commit comments

Comments
 (0)