diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-03-29 04:03:49 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 13:03:49 -0400 |
commit | bced52505f32d6cca4f944bb610a8a26767908a8 (patch) | |
tree | da49a5df4b7bd6f8306248069228cd6bd0db1303 /cli/js/web/dom_util.ts | |
parent | 1397b8e0e7c85762e19d88fde103342bfa563360 (diff) |
Update to Prettier 2 and use ES Private Fields (#4498)
Diffstat (limited to 'cli/js/web/dom_util.ts')
-rw-r--r-- | cli/js/web/dom_util.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cli/js/web/dom_util.ts b/cli/js/web/dom_util.ts index 5780d9c52..40a8c618f 100644 --- a/cli/js/web/dom_util.ts +++ b/cli/js/web/dom_util.ts @@ -2,6 +2,23 @@ // Utility functions for DOM nodes import * as domTypes from "./dom_types.ts"; +export function getDOMStringList(arr: string[]): domTypes.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 unknown) as domTypes.DOMStringList; +} + export function isNode(nodeImpl: domTypes.EventTarget | null): boolean { return Boolean(nodeImpl && "nodeType" in nodeImpl); } |