web.dom-collections.iterator.js 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. var global = require('../internals/global');
  2. var DOMIterables = require('../internals/dom-iterables');
  3. var ArrayIteratorMethods = require('../modules/es.array.iterator');
  4. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  5. var wellKnownSymbol = require('../internals/well-known-symbol');
  6. var ITERATOR = wellKnownSymbol('iterator');
  7. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  8. var ArrayValues = ArrayIteratorMethods.values;
  9. for (var COLLECTION_NAME in DOMIterables) {
  10. var Collection = global[COLLECTION_NAME];
  11. var CollectionPrototype = Collection && Collection.prototype;
  12. if (CollectionPrototype) {
  13. // some Chrome versions have non-configurable methods on DOMTokenList
  14. if (CollectionPrototype[ITERATOR] !== ArrayValues) try {
  15. createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);
  16. } catch (error) {
  17. CollectionPrototype[ITERATOR] = ArrayValues;
  18. }
  19. if (!CollectionPrototype[TO_STRING_TAG]) {
  20. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  21. }
  22. if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {
  23. // some Chrome versions have non-configurable methods on DOMTokenList
  24. if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {
  25. createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
  26. } catch (error) {
  27. CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
  28. }
  29. }
  30. }
  31. }