-
Notifications
You must be signed in to change notification settings - Fork 38
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
Performance fixes #75
Conversation
by using fastdom to batch DOM measurement and mutation tasks.
element.textContent = 'Hello'; | ||
target.appendChild(element); | ||
|
||
setTimeout(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These nested timeouts look like they must have been a pain to work with, but the tests all pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They were definitely a pain. I tried using jasmine's mock clock instead, but it didn't work. From what I could tell from stack overflow posts, jasmine doesn't mock out enough to be able to trigger the mutation observers. setTimeout was the best I could do. I'm open to suggestions for better ways to do it. I'm also hoping that if we convert to jest, we'll be able to rewrite these tests to get rid of the setTimeouts.
This PR addresses performance issues with Just Not Sorry on long emails.
In version 1.6.2 (and earlier), a long email with many just's and sorry's will slow typing performance to a crawl. As noted in #65 this is because on each keystroke, the code is removing and re-adding all of the warnings. This causes layout thrashing and greatly reduces performance as the browser tries to catch up.
This PR makes the following changes to improve performance:
It also adds more test coverage for the mutation observer-related code.
Fixes #65