Skip to content

Commit

Permalink
Revert "Revert "Added removeChildElements helper""
Browse files Browse the repository at this point in the history
This reverts commit 8f6784a.
  • Loading branch information
alexiglesias93 committed Apr 25, 2021
1 parent 8f6784a commit e6b35e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { default as wait } from './wait';
export { default as throwError } from './throwError';
export { default as selectInputElement } from './selectInputElement';
export { default as queryElement } from './queryElement';
export { default as removeChildElements } from './removeChildElements';
export { default as isVisible } from './isVisible';
export { default as isScrollable } from './isScrollable';
export { default as getObjectKeys } from './getObjectKeys';
Expand Down
11 changes: 11 additions & 0 deletions helpers/removeChildElements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Remove all child elements from a parent element
* @param element Parent element
* @param selector Optional: only remove the elements that match this selector
*/
const removeChildElements = (element: Element, selector?: string): void => {
const childElements = element.querySelectorAll(selector || '*');
childElements.forEach((childElement) => childElement.remove());
};

export default removeChildElements;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@finsweet/ts-utils",
"version": "0.1.1",
"version": "0.2.0",
"description": "Typescript utils for custom Webflow projects.",
"main": "index.ts",
"module": "index.ts",
Expand Down

0 comments on commit e6b35e4

Please sign in to comment.