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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Trick Closure compiler to preserve reflow codepath #19367

Merged
merged 2 commits into from Nov 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion extensions/amp-gwd-animation/0.1/amp-gwd-animation-impl.js
Expand Up @@ -498,5 +498,10 @@ export class AmpGwdRuntimeService {
* @param {!Element} element
*/
function reflow(element) {
return element./*OK*/offsetWidth;
// exporting global to trick Closure into thinking this function has side
// effects.
const globalRef = '__AMP_GWD_TEMP';
// Reading `offsetWidth` is what actually causes reflow.
self[globalRef] = element./*OK*/offsetWidth;
delete self[globalRef];
}