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

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