UNPKG

@blueprintjs/core

Version:
46 lines (45 loc) 1.58 kB
/* * Copyright 2015 Palantir Technologies, Inc. All rights reserved. * * Licensed under the terms of the LICENSE file distributed with this project. */ import * as tslib_1 from "tslib"; /** A collection of curated prop keys used across our Components which are not valid HTMLElement props. */ var INVALID_PROPS = [ "active", "containerRef", "elementRef", "iconName", "inputRef", "intent", "inline", "loading", "leftIconName", "onChildrenMount", "onRemove", "popoverProps", "rightElement", "rightIconName", "text", ]; /** * Typically applied to HTMLElements to filter out blacklisted props. When applied to a Component, * can filter props from being passed down to the children. Can also filter by a combined list of * supplied prop keys and the blacklist (only appropriate for HTMLElements). * @param props The original props object to filter down. * @param {string[]} invalidProps If supplied, overwrites the default blacklist. * @param {boolean} shouldMerge If true, will merge supplied invalidProps and blacklist together. */ export function removeNonHTMLProps(props, invalidProps, shouldMerge) { if (invalidProps === void 0) { invalidProps = INVALID_PROPS; } if (shouldMerge === void 0) { shouldMerge = false; } if (shouldMerge) { invalidProps = invalidProps.concat(INVALID_PROPS); } return invalidProps.reduce(function (prev, curr) { if (prev.hasOwnProperty(curr)) { delete prev[curr]; } return prev; }, tslib_1.__assign({}, props)); }