diff options
author | Kyra <kyradiscord@gmail.com> | 2018-11-04 19:05:02 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-11-04 10:05:02 -0800 |
commit | e93d686e9d5e797f7e4e02bda56a8b6d535326ca (patch) | |
tree | e89490da61e17ee890ce590fdaa99d0701dc8308 /js/mixins | |
parent | 1241b8e9babfec3e87c8958e2065966ee5dd1335 (diff) |
Web APIs: `File` and `FormData` (#1056)
Diffstat (limited to 'js/mixins')
-rw-r--r-- | js/mixins/dom_iterable.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/js/mixins/dom_iterable.ts b/js/mixins/dom_iterable.ts index 015226589..eb5d08d13 100644 --- a/js/mixins/dom_iterable.ts +++ b/js/mixins/dom_iterable.ts @@ -21,22 +21,27 @@ export function DomIterableMixin<K, V, TBase extends Constructor>( // Base class in a way where the Symbol `dataSymbol` is defined. So the // runtime code works, but we do lose a little bit of type safety. + // Additionally, we have to not use .keys() nor .values() since the internal + // slot differs in type - some have a Map, which yields [K, V] in + // Symbol.iterator, and some have an Array, which yields V, in this case + // [K, V] too as they are arrays of tuples. + // tslint:disable-next-line:variable-name const DomIterable = class extends Base { *entries(): IterableIterator<[K, V]> { - for (const entry of (this as any)[dataSymbol].entries()) { + for (const entry of (this as any)[dataSymbol]) { yield entry; } } *keys(): IterableIterator<K> { - for (const key of (this as any)[dataSymbol].keys()) { + for (const [key] of (this as any)[dataSymbol]) { yield key; } } *values(): IterableIterator<V> { - for (const value of (this as any)[dataSymbol].values()) { + for (const [, value] of (this as any)[dataSymbol]) { yield value; } } @@ -47,7 +52,7 @@ export function DomIterableMixin<K, V, TBase extends Constructor>( thisArg?: any ): void { callbackfn = callbackfn.bind(thisArg == null ? window : Object(thisArg)); - for (const [key, value] of (this as any)[dataSymbol].entries()) { + for (const [key, value] of (this as any)[dataSymbol]) { callbackfn(value, key, this); } } |