Remove isHostObject helper.

This commit is contained in:
John-David Dalton
2016-08-13 13:26:29 -07:00
parent 5cca51e978
commit a6a3f3ed80
3 changed files with 12 additions and 52 deletions

View File

@@ -56,15 +56,14 @@ before_install:
# Remove code skipped on the coverage run. # Remove code skipped on the coverage run.
- | - |
PATTERN[0]="|\s*if\s*\(isHostObject\b[\s\S]+?\}(?=\n)|" PATTERN[0]="|\s*if\s*\(enumerate\b[\s\S]+?\};\s*\}|"
PATTERN[1]="|\s*if\s*\(enumerate\b[\s\S]+?\};\s*\}|" PATTERN[1]="|\s*while\s*\([^)]+\)\s*\{\s*iteratee\(index\);\s*\}|"
PATTERN[2]="|\s*while\s*\([^)]+\)\s*\{\s*iteratee\(index\);\s*\}|" PATTERN[2]="|\s*else\s*\{\s*assocSet\(data\b[\s\S]+?\}|"
PATTERN[3]="|\s*else\s*\{\s*assocSet\(data\b[\s\S]+?\}|" PATTERN[3]="|\bcase\s+(?:dataView|promise|set|map|weakMap)CtorString:.+|g"
PATTERN[4]="|\bcase\s+(?:dataView|promise|set|map|weakMap)CtorString:.+|g" PATTERN[4]="|\bindex,\s*iterable\)\s*===\s*false\)[^}]+?(break;)|"
PATTERN[5]="|\bindex,\s*iterable\)\s*===\s*false\)[^}]+?(break;)|" PATTERN[5]="|\s*if\s*\(\!lodashFunc\)\s*\{\s*return;\s*\}|"
PATTERN[6]="|\s*if\s*\(\!lodashFunc\)\s*\{\s*return;\s*\}|" PATTERN[6]="|\s*define\([\s\S]+?\);|"
PATTERN[7]="|\s*define\([\s\S]+?\);|" PATTERN[7]="|\s*root\._\s*=\s*_;|"
PATTERN[8]="|\s*root\._\s*=\s*_;|"
if [ $ISTANBUL == true ]; then if [ $ISTANBUL == true ]; then
set -e set -e

View File

@@ -1164,25 +1164,6 @@
return reHasUnicodeWord.test(string); return reHasUnicodeWord.test(string);
} }
/**
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/
function isHostObject(value) {
// Many host objects are `Object` objects that can coerce to strings
// despite having improperly defined `toString` methods.
var result = false;
if (value != null && typeof value.toString != 'function') {
try {
result = !!(value + '');
} catch (e) {}
}
return result;
}
/** /**
* Converts `iterator` to an array. * Converts `iterator` to an array.
* *
@@ -2532,9 +2513,6 @@
return cloneBuffer(value, isDeep); return cloneBuffer(value, isDeep);
} }
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
if (isHostObject(value)) {
return object ? value : {};
}
result = initCloneObject(isFunc ? {} : value); result = initCloneObject(isFunc ? {} : value);
if (!isDeep) { if (!isDeep) {
return copySymbols(value, baseAssign(result, value)); return copySymbols(value, baseAssign(result, value));
@@ -3178,8 +3156,8 @@
othTag = getTag(other); othTag = getTag(other);
othTag = othTag == argsTag ? objectTag : othTag; othTag = othTag == argsTag ? objectTag : othTag;
} }
var objIsObj = objTag == objectTag && !isHostObject(object), var objIsObj = objTag == objectTag,
othIsObj = othTag == objectTag && !isHostObject(other), othIsObj = othTag == objectTag,
isSameTag = objTag == othTag; isSameTag = objTag == othTag;
if (isSameTag && !objIsObj) { if (isSameTag && !objIsObj) {
@@ -3284,7 +3262,7 @@
if (!isObject(value) || isMasked(value)) { if (!isObject(value) || isMasked(value)) {
return false; return false;
} }
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value)); return pattern.test(toSource(value));
} }
@@ -11713,8 +11691,7 @@
* // => true * // => true
*/ */
function isPlainObject(value) { function isPlainObject(value) {
if (!isObjectLike(value) || if (!isObjectLike(value) || objectToString.call(value) != objectTag) {
objectToString.call(value) != objectTag || isHostObject(value)) {
return false; return false;
} }
var proto = getPrototype(value); var proto = getPrototype(value);

View File

@@ -10495,22 +10495,6 @@
} }
}); });
QUnit.test('should work with host objects in IE 8 document mode (test in IE 11)', function(assert) {
assert.expect(2);
// Trigger a Chakra JIT bug.
// See https://github.com/jashkenas/underscore/issues/1621.
lodashStable.each([body, xml], function(object) {
if (object) {
lodashStable.times(100, _.isFunction);
assert.strictEqual(_.isFunction(object), false);
}
else {
skipAssert(assert);
}
});
});
QUnit.test('should work with a function from another realm', function(assert) { QUnit.test('should work with a function from another realm', function(assert) {
assert.expect(1); assert.expect(1);