UNPKG

carbon-custom-elements

Version:

A Carbon Design System variant that's as easy to use as native HTML elements, with no framework tax, no framework silo.

1 lines 798 B
{"version":3,"sources":["polyfills/element-closest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG","file":"element-closest.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2019\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (typeof Element.prototype.closest !== 'function') {\n Element.prototype.closest = function closestElement(selector: string) {\n const doc = this.ownerDocument;\n for (let traverse: Node | null = this; traverse && traverse !== doc; traverse = traverse.parentNode) {\n if (traverse.nodeType === Node.ELEMENT_NODE && (traverse as Element).matches(selector)) {\n return traverse as Element;\n }\n }\n return null;\n };\n}\n"]}