summaryrefslogtreecommitdiff
path: root/packages/frontend/src/utility/element-contains.ts
diff options
context:
space:
mode:
authormisskey-release-bot[bot] <157398866+misskey-release-bot[bot]@users.noreply.github.com>2026-03-05 10:56:50 +0000
committerGitHub <noreply@github.com>2026-03-05 10:56:50 +0000
commitfe3dd8edb5f30104cd0a7ed755eb254feda2922d (patch)
treeaf6cf5fa4ca75302ac2de5db742cead00bc13d21 /packages/frontend/src/utility/element-contains.ts
parentMerge pull request #16998 from misskey-dev/develop (diff)
parentRelease: 2026.3.0 (diff)
downloadmisskey-fe3dd8edb5f30104cd0a7ed755eb254feda2922d.tar.gz
misskey-fe3dd8edb5f30104cd0a7ed755eb254feda2922d.tar.bz2
misskey-fe3dd8edb5f30104cd0a7ed755eb254feda2922d.zip
Merge pull request #17217 from misskey-dev/develop
Release: 2026.3.0
Diffstat (limited to 'packages/frontend/src/utility/element-contains.ts')
-rw-r--r--packages/frontend/src/utility/element-contains.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/frontend/src/utility/element-contains.ts b/packages/frontend/src/utility/element-contains.ts
new file mode 100644
index 0000000000..8389d49278
--- /dev/null
+++ b/packages/frontend/src/utility/element-contains.ts
@@ -0,0 +1,15 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+export function elementContains(parent: Element | null, child: Element | null, checkSame = true) {
+ if (parent === null || child === null) return false;
+ if (checkSame && parent === child) return true;
+ let node = child.parentNode;
+ while (node) {
+ if (node === parent) return true;
+ node = node.parentNode;
+ }
+ return false;
+}