Spaces:
Build error
Build error
Adrien Denat
commited on
Commit
•
64263c4
1
Parent(s):
ca616cc
fix deepestChild function throwing error (#213)
Browse files* fix deepestChild function throwing error
* let -> const
* remove unecessary var
src/lib/utils/deepestChild.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
-
export function deepestChild(el: HTMLElement) {
|
2 |
-
|
3 |
-
|
4 |
-
newEl = newEl.lastElementChild as HTMLElement;
|
5 |
}
|
6 |
-
return
|
7 |
}
|
|
|
1 |
+
export function deepestChild(el: HTMLElement): HTMLElement {
|
2 |
+
if (el.lastElementChild && el.lastElementChild.nodeType !== Node.TEXT_NODE) {
|
3 |
+
return deepestChild(el.lastElementChild as HTMLElement);
|
|
|
4 |
}
|
5 |
+
return el;
|
6 |
}
|