Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

_.isEqual for DOM elements always returns true #945

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+21 −0
Split
View
@@ -358,6 +358,23 @@ $(document).ready(function() {
// Objects from another frame.
ok(_.isEqual({}, iObject));
+
+ // DOM elements
+ var aDom = document.createElement('div'),
+ bDom = document.createElement('span'),
+ $aDom = $(aDom),
+ $bDom = $(bDom),
+ $allDoms = $aDom.add($bDom);
+
+ ok(!_.isEqual(aDom, bDom), 'DOM Elements are not always equal.');
+
+ ok(!_.isEqual($aDom, $bDom), 'jQuery DOM Elements are not always equal.');
+
+ ok(_.isEqual(aDom, aDom), 'Same DOM Elements are equal.');
+
+ ok(_.isEqual($aDom, $aDom), 'Same jQuery DOM Elements are equal.');
+
+ ok(_.isEqual($allDoms, $allDoms), 'Same jQuery Elements are equal.');
});
test("isEmpty", function() {
View
@@ -828,6 +828,10 @@
// Unwrap any wrapped objects.
if (a instanceof _) a = a._wrapped;
if (b instanceof _) b = b._wrapped;
+ // Compare DOM elements.
+ if (a && a.nodeName || b && b.nodeName) {
+ return a === b;
+ }
// Compare `[[Class]]` names.
var className = toString.call(a);
if (className != toString.call(b)) return false;