Skip to content

Commit

Permalink
Remove type casting
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Feb 25, 2024
1 parent 1fd2d07 commit e2b0935
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/morphlex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/morphlex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ function morphAttributes(elem: Element, guide: Element): void {
else if (isTextArea(elem) && isTextArea(guide)) {
if (elem.value !== guide.value) elem.value = guide.value;

// TextAreas only have one child node and it’s always a text node, so we can safely cast here.
const text = elem.firstChild as Text | null;
if (text && text.textContent !== guide.value) text.textContent = guide.value;
const text = elem.firstChild;
if (text && isText(text) && text.textContent !== guide.value) text.textContent = guide.value;
}
}

Expand Down

0 comments on commit e2b0935

Please sign in to comment.