0026506543
- prettier's formatting has changed, so files needed to be reformatted - dart is spitting out deprecation warnings like: 254 │ 2: $spacer / 2, │ ^^^^^^^^^^^ ╵ bazel-out/darwin-fastbuild/bin/ts/sass/bootstrap/_variables.scss 254:6 @import ts/sass/button_mixins.scss 2:9 @use ts/components/ColorPicker.svelte 2:5 root stylesheet DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0. Recommendation: math.div($grid-gutter-width, 2)
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
export function removeNode(element: Node): void {
|
|
element.parentNode?.removeChild(element);
|
|
}
|
|
|
|
function iterateElement(
|
|
filter: (node: Node) => void,
|
|
fragment: DocumentFragment | Element
|
|
): void {
|
|
for (const child of [...fragment.childNodes]) {
|
|
filter(child);
|
|
}
|
|
}
|
|
|
|
export const filterNode =
|
|
(elementFilter: (element: Element) => void) =>
|
|
(node: Node): void => {
|
|
switch (node.nodeType) {
|
|
case Node.COMMENT_NODE:
|
|
removeNode(node);
|
|
break;
|
|
|
|
case Node.DOCUMENT_FRAGMENT_NODE:
|
|
iterateElement(filterNode(elementFilter), node as DocumentFragment);
|
|
break;
|
|
|
|
case Node.ELEMENT_NODE:
|
|
iterateElement(filterNode(elementFilter), node as Element);
|
|
elementFilter(node as Element);
|
|
break;
|
|
|
|
default:
|
|
// do nothing
|
|
}
|
|
};
|