object-get-own-property-names-external.js 784 B

1234567891011121314151617181920212223
  1. /* eslint-disable es/no-object-getownpropertynames -- safe */
  2. var toIndexedObject = require('../internals/to-indexed-object');
  3. var $getOwnPropertyNames = require('../internals/object-get-own-property-names').f;
  4. var toString = {}.toString;
  5. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  6. ? Object.getOwnPropertyNames(window) : [];
  7. var getWindowNames = function (it) {
  8. try {
  9. return $getOwnPropertyNames(it);
  10. } catch (error) {
  11. return windowNames.slice();
  12. }
  13. };
  14. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  15. module.exports.f = function getOwnPropertyNames(it) {
  16. return windowNames && toString.call(it) == '[object Window]'
  17. ? getWindowNames(it)
  18. : $getOwnPropertyNames(toIndexedObject(it));
  19. };