mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Ensure _.matches and _.matchesProperty work with function value params.
This commit is contained in:
@@ -2326,7 +2326,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)) && !isHostObject(object),
|
var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)) && !isHostObject(object),
|
||||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
othIsObj = (othTag == objectTag || (isLoose && othTag == funcTag)) && !isHostObject(other),
|
||||||
isSameTag = objTag == othTag;
|
isSameTag = objTag == othTag;
|
||||||
|
|
||||||
if (isSameTag && !(objIsArr || objIsObj)) {
|
if (isSameTag && !(objIsArr || objIsObj)) {
|
||||||
|
|||||||
20
test/test.js
20
test/test.js
@@ -9494,6 +9494,16 @@
|
|||||||
strictEqual(matches(object), true);
|
strictEqual(matches(object), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should match properties when `value` is a function', 1, function() {
|
||||||
|
function Foo() {}
|
||||||
|
Foo.a = function() {};
|
||||||
|
Foo.a.b = 1;
|
||||||
|
Foo.a.c = 2;
|
||||||
|
|
||||||
|
var matches = _.matches({ 'a': { 'b': 1 } });
|
||||||
|
strictEqual(matches(Foo), true);
|
||||||
|
});
|
||||||
|
|
||||||
test('should match properties when `value` is not a plain object', 1, function() {
|
test('should match properties when `value` is not a plain object', 1, function() {
|
||||||
function Foo(object) { _.assign(this, object); }
|
function Foo(object) { _.assign(this, object); }
|
||||||
|
|
||||||
@@ -9672,6 +9682,16 @@
|
|||||||
strictEqual(matches(object), true);
|
strictEqual(matches(object), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should match properties when `value` is a function', 1, function() {
|
||||||
|
function Foo() {}
|
||||||
|
Foo.a = function() {};
|
||||||
|
Foo.a.b = 1;
|
||||||
|
Foo.a.c = 2;
|
||||||
|
|
||||||
|
var matches = _.matchesProperty('a', { 'b': 1 });
|
||||||
|
strictEqual(matches(Foo), true);
|
||||||
|
});
|
||||||
|
|
||||||
test('should match properties when `value` is not a plain object', 1, function() {
|
test('should match properties when `value` is not a plain object', 1, function() {
|
||||||
function Foo(object) { _.assign(this, object); }
|
function Foo(object) { _.assign(this, object); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user