Skip to content

Commit

Permalink
removed defensive checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Feb 15, 2023
1 parent 14fd717 commit cb83064
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions packages/mui-base/src/TextareaAutosize/TextareaAutosize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,20 @@ const TextareaAutosize = React.forwardRef(function TextareaAutosize(
}
});
let resizeObserver: ResizeObserver;
let containerWindow: Window;
if (inputRef.current) {
containerWindow = ownerWindow(inputRef.current);
containerWindow.addEventListener('resize', handleResize);

if (typeof ResizeObserver !== 'undefined') {
resizeObserver = new ResizeObserver(handleResize);
resizeObserver.observe(inputRef.current);
}

const input = inputRef.current!;
const containerWindow = ownerWindow(input);

containerWindow.addEventListener('resize', handleResize);

if (typeof ResizeObserver !== 'undefined') {
resizeObserver = new ResizeObserver(handleResize);
resizeObserver.observe(input);
}

return () => {
handleResize.clear();
if (containerWindow) {
containerWindow.removeEventListener('resize', handleResize);
}
containerWindow.removeEventListener('resize', handleResize);
if (resizeObserver) {
resizeObserver.disconnect();
}
Expand Down

0 comments on commit cb83064

Please sign in to comment.