Skip to content

Rule svelte/no-dom-manipulating throws errors when reading properties #378

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

Closed
2 tasks done
robinloeffel opened this issue Feb 17, 2023 · 0 comments · Fixed by #383
Closed
2 tasks done

Rule svelte/no-dom-manipulating throws errors when reading properties #378

robinloeffel opened this issue Feb 17, 2023 · 0 comments · Fixed by #383
Labels
bug Something isn't working

Comments

@robinloeffel
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

8.34.0

What version of eslint-plugin-svelte are you using?

2.19.0

What did you do?

With the following snippet, the rule svelte/no-dom-manipulating throws the following error:

let mobileExpandContent: HTMLDivElement;
let mobileMenuExpandedHeight = "";

// ...

mobileMenuExpandedHeight = `${mobileExpandContent.clientHeight}px`;

// ...

<div bind:this={mobileExpandContent}></div>
Don't manipulate the DOM directly. The Svelte runtime can get confused if there is a difference between the actual DOM and the DOM expected by the Svelte runtime.eslint[svelte/no-dom-manipulating](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dom-manipulating/)

The rule is configured to simply "svelte/no-dom-manipulating": "error".

What did you expect to happen?

I would not expect the rule to go off when only reading DOM properties.

What actually happened?

The rule went off.

Link to GitHub Repo with Minimal Reproducible Example

n/a; You can reproduce it on the playground of the rule by trying to access the clientHeight of one of the referenced DOM nodes.

Additional comments

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants