Skip to content

Commit

Permalink
馃悰 Trick Closure compiler to preserve reflow codepath (ampproject#19367)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco authored and Enriqe committed Nov 28, 2018
1 parent 6d32015 commit b40bea8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion extensions/amp-gwd-animation/0.1/amp-gwd-animation-impl.js
Expand Up @@ -551,5 +551,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];
}

0 comments on commit b40bea8

Please sign in to comment.