1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-14 16:33:45 -05:00
denoland-deno/cli/js/web/dom_util.ts

19 lines
485 B
TypeScript
Raw Normal View History

2020-01-02 15:13:47 -05:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
export function getDOMStringList(arr: string[]): DOMStringList {
Object.defineProperties(arr, {
contains: {
value(searchElement: string): boolean {
return arr.includes(searchElement);
},
enumerable: true,
},
item: {
value(idx: number): string | null {
return idx in arr ? arr[idx] : null;
},
},
});
return arr as string[] & DOMStringList;
2019-05-27 09:20:34 -04:00
}