$.get-names.js 608 B

1234567891011121314151617181920
  1. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  2. var toIObject = require('./$.to-iobject')
  3. , getNames = require('./$').getNames
  4. , toString = {}.toString;
  5. var windowNames = typeof window == 'object' && Object.getOwnPropertyNames
  6. ? Object.getOwnPropertyNames(window) : [];
  7. var getWindowNames = function(it){
  8. try {
  9. return getNames(it);
  10. } catch(e){
  11. return windowNames.slice();
  12. }
  13. };
  14. module.exports.get = function getOwnPropertyNames(it){
  15. if(windowNames && toString.call(it) == '[object Window]')return getWindowNames(it);
  16. return getNames(toIObject(it));
  17. };