Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(comp:textarea): measureTextarea removeChild error #1492

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/components/textarea/src/utils/measureTextarea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export function measureTextarea<V>(

textarea.parentNode!.appendChild(clonedTextarea)
const measureRes = measureFn(clonedTextarea)
textarea.parentNode!.removeChild(clonedTextarea)
if (clonedTextarea.parentNode) {
clonedTextarea.parentNode.removeChild(clonedTextarea)
}

return measureRes
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a brief review of the code patch

The patch adds an extra conditional check to ensure that the clonedTextarea element has a parent node before proceeding to delete it. This is a good practice as it ensures that any dependencies to the element are handled properly and prevents potential errors. The code also looks well structured and it is easy to read. Therefore, I suggest no changes to this code.