web.dom.iterable.js 881 B

12345678910111213141516171819202122
  1. var $iterators = require('./es6.array.iterator')
  2. , redefine = require('./_redefine')
  3. , global = require('./_global')
  4. , hide = require('./_hide')
  5. , Iterators = require('./_iterators')
  6. , wks = require('./_wks')
  7. , ITERATOR = wks('iterator')
  8. , TO_STRING_TAG = wks('toStringTag')
  9. , ArrayValues = Iterators.Array;
  10. for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
  11. var NAME = collections[i]
  12. , Collection = global[NAME]
  13. , proto = Collection && Collection.prototype
  14. , key;
  15. if(proto){
  16. if(!proto[ITERATOR])hide(proto, ITERATOR, ArrayValues);
  17. if(!proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
  18. Iterators[NAME] = ArrayValues;
  19. for(key in $iterators)if(!proto[key])redefine(proto, key, $iterators[key], true);
  20. }
  21. }