1 | import { EMPTY_ARR } from "./constants";
|
2 |
|
3 | /**
|
4 | * Assign properties from `props` to `obj`
|
5 | * @template O, P The obj and props types
|
6 | * @param {O} obj The object to copy properties to
|
7 | * @param {P} props The object to copy properties from
|
8 | * @returns {O & P}
|
9 | */
|
10 | export function assign(obj, props) {
|
11 | // @ts-ignore We change the type of `obj` to be `O & P`
|
12 | for (let i in props) obj[i] = props[i];
|
13 | return /** @type {O & P} */ (obj);
|
14 | }
|
15 |
|
16 | /**
|
17 | * Remove a child node from its parent if attached. This is a workaround for
|
18 | * IE11 which doesn't support `Element.prototype.remove()`. Using this function
|
19 | * is smaller than including a dedicated polyfill.
|
20 | * @param {Node} node The node to remove
|
21 | */
|
22 | export function removeNode(node) {
|
23 | let parentNode = node.parentNode;
|
24 | if (parentNode) parentNode.removeChild(node);
|
25 | }
|
26 |
|
27 | export const slice = EMPTY_ARR.slice;
|