-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 js animation not disable if load jquery in body #2440
Fix js animation not disable if load jquery in body #2440
Conversation
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.
I believe the original intent was for defer
to handle this use case, but that isn't happening because defer
is only for external scripts (ignored for inline). Please remove the defer
attribute along when making fixes for this PR
spec/shared_selenium_session.rb
Outdated
@@ -405,7 +405,9 @@ | |||
@animation_session.visit('with_animation') | |||
scroll_y = @animation_session.evaluate_script(<<~JS) | |||
(function(){ | |||
window.scrollTo(0,500); | |||
$('html, body').animate({ |
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.
@why are you modifying this test? If you want to test different behavior add a new test.
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.
🆗
@@ -77,6 +63,20 @@ | |||
<a href='#' class='animation' onclick='this.classList.add("away")' oncontextmenu='this.classList.add("pseudo")'> | |||
animate me away | |||
</a> | |||
<script src="/jquery.js" type="text/javascript" charset="utf-8"></script> |
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.
If a new view is needed for new tests please create it rather than modifying the existing one.
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.
🆗
58129e0
to
f95e581
Compare
LGTM - thanks |
Animation disabler now can only turn off the animation come from jQuery if jQuery is loaded in head, because
insert_disable
place the template at the end of head.capybara/lib/capybara/server/animation_disabler.rb
Lines 42 to 44 in a08e047
If jQuery is loaded with the body, jQuery will be undefined in head so the function won't work.
capybara/lib/capybara/server/animation_disabler.rb
Lines 46 to 49 in a08e047
By placing it to the end of the body, developer do not have to worry about where they are loading jQuery and give a better experience 😄