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

Items not animating after code was minified by Closure Compiler #1492

Closed
thheller opened this issue Apr 17, 2019 · 5 comments
Closed

Items not animating after code was minified by Closure Compiler #1492

thheller opened this issue Apr 17, 2019 · 5 comments

Comments

@thheller
Copy link

I'm investigating an issue where SortableJS doesn't animate when sorting after the code was optimized by the Closure Compiler. This seems to be an issue in the Closure Compiler itself but maybe you have some insight into what might be happening.

The list remains fully sortable it just doesn't animate anymore.

I created a simple repro here:
https://github.com/thheller/sortablejs-closure-issue

Working:
https://thheller.github.io/sortablejs-closure-issue/demo.html
Working but not animating:
https://thheller.github.io/sortablejs-closure-issue/demo-closure.html

@owen-m1
Copy link
Member

owen-m1 commented Apr 17, 2019

@thheller Not sure. Seems like an issue with Closure. Maybe also try with this PR: #1340

@thheller
Copy link
Author

@owen-m1 Yes, that's exactly it.

I think Angular also uses the Closure Compiler. I can expand a bit on what is happening. If Closure sees an assignment that is never used anywhere it will decide to optimize it away. Unfortunately it doesn't identify that accessing .offsetWidth is actually a CSS trigger that shouldn't be removed.

In the Closure Library there is the concept of goog.reflect.sinkValue(target.offsetWidth) [1] which will be optimized to just target.offsetWidth after compilation. The goog.reflect.sinkValue just tells the compiler to not remove the inner expression.

The _repaint trick seems to achieve the same thing.

[1] https://github.com/google/closure-library/blob/master/closure/goog/reflect/reflect.js#L60-L81

owen-m1 added a commit that referenced this issue Apr 19, 2019
@owen-m1
Copy link
Member

owen-m1 commented Apr 19, 2019

@thheller Try master branch

@thheller
Copy link
Author

The issue is fixed in master.

@p-himik
Copy link

p-himik commented Oct 9, 2019

Unfortunately, this is still an issue in 1.10.1. The whole call to repaint is removed completely.
Perhaps something similar to what goog.reflect.sinkValue does could be used to prevent that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants