isHostObject.js 550 B

1234567891011121314151617181920
  1. /**
  2. * Checks if `value` is a host object in IE < 9.
  3. *
  4. * @private
  5. * @param {*} value The value to check.
  6. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  7. */
  8. function isHostObject(value) {
  9. // Many host objects are `Object` objects that can coerce to strings
  10. // despite having improperly defined `toString` methods.
  11. var result = false;
  12. if (value != null && typeof value.toString != 'function') {
  13. try {
  14. result = !!(value + '');
  15. } catch (e) {}
  16. }
  17. return result;
  18. }
  19. export default isHostObject;