Skip to content

Commit 6fcaa77

Browse files
committed
Merge remote-tracking branch 'akre/doc-updates'
2 parents 6d0d16f + d36a843 commit 6fcaa77

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

Diff for: index.html

+24
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,30 @@ <h2 id="changelog">Change Log</h2>
20662066
<li>
20672067
<tt>_.has</tt> now guards against nullish objects.
20682068
</li>
2069+
<li>
2070+
<tt>_.omit</tt> can now take an iteratee function.
2071+
</li>
2072+
<li>
2073+
<tt>_.partition</tt> is now called with <tt>index</tt> and <tt>object</tt>.
2074+
</li>
2075+
<li>
2076+
<tt>_.matches</tt> creates a shallow clone of your object and only iterates
2077+
over own properties.
2078+
</li>
2079+
<li>
2080+
Aligning better with the forthcoming ECMA6 <tt>Object.assign</tt>,
2081+
<tt>_.extend</tt> only iterates over the object's own properties.
2082+
</li>
2083+
<li>
2084+
Falsey guards are no longer needed in <tt>_.extend</tt> and
2085+
<tt>_.defaults</tt>&mdash;if the passed in argument isn't a JavaScript
2086+
object it's just returned.
2087+
</li>
2088+
<li>
2089+
Fixed a few edge cases in <tt>_.max</tt> and <tt>_.min</tt> to
2090+
handle arrays containing <tt>NaN</tt> (like strings or other objects)
2091+
and <tt>Infinity</tt> and <tt>-Infinity</tt>.
2092+
</li>
20692093
<li>
20702094
Override base methods like <tt>each</tt> and <tt>some</tt>
20712095
and they'll be used internally by other Underscore functions too.

Diff for: test/collections.js

+23-8
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,7 @@
7979
doubled = _([1, 2, 3]).map(function(num){ return num * 2; });
8080
deepEqual(doubled, [2, 4, 6], 'OO-style doubled numbers');
8181

82-
if (typeof document != 'undefined') {
83-
var nodes = _.filter(document.getElementById('map-test').childNodes, _.isElement);
84-
var ids = _.map(nodes, 'id');
85-
equal(nodes.length, 2);
86-
deepEqual(ids, ['id1', 'id2'], 'Can use collection methods on NodeLists.');
87-
}
88-
89-
ids = _.map({length: 2, 0: {id: '1'}, 1: {id: '2'}}, function(n){
82+
var ids = _.map({length: 2, 0: {id: '1'}, 1: {id: '2'}}, function(n){
9083
return n.id;
9184
});
9285
deepEqual(ids, ['1', '2'], 'Can use collection methods on Array-likes.');
@@ -711,4 +704,26 @@
711704
}, predicate);
712705
});
713706

707+
if (typeof document != 'undefined') {
708+
test('Can use various collection methods on NodeLists', function() {
709+
var parent = document.createElement('div');
710+
parent.innerHTML = '<span id=id1></span>textnode<span id=id2></span>';
711+
712+
var elementChildren = _.filter(parent.childNodes, _.isElement);
713+
equal(elementChildren.length, 2);
714+
715+
deepEqual(_.map(elementChildren, 'id'), ['id1', 'id2']);
716+
deepEqual(_.map(parent.childNodes, 'nodeType'), [1, 3, 1]);
717+
718+
ok(!_.every(parent.childNodes, _.isElement));
719+
ok(_.some(parent.childNodes, _.isElement));
720+
721+
function compareNode(node) {
722+
return _.isElement(node) ? node.id.charAt(2) : void 0;
723+
}
724+
equal(_.max(parent.childNodes, compareNode), _.last(parent.childNodes));
725+
equal(_.min(parent.childNodes, compareNode), _.first(parent.childNodes));
726+
});
727+
}
728+
714729
}());

Diff for: test/index.html

-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
</head>
88
<body>
99
<div id="qunit"></div>
10-
<div id="qunit-fixture">
11-
<div id="map-test">
12-
<div id="id1"></div>
13-
<div id="id2"></div>
14-
</div>
15-
</div>
1610
<script src="vendor/qunit.js"></script>
1711
<script src="../underscore.js"></script>
1812

0 commit comments

Comments
 (0)