From b40bea896b50454ea1bb0cf8fc2edec475537f50 Mon Sep 17 00:00:00 2001 From: Alan Orozco Date: Fri, 16 Nov 2018 13:54:06 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Trick=20Closure=20compiler=20to?= =?UTF-8?q?=20preserve=20reflow=20codepath=20(#19367)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/amp-gwd-animation/0.1/amp-gwd-animation-impl.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/amp-gwd-animation/0.1/amp-gwd-animation-impl.js b/extensions/amp-gwd-animation/0.1/amp-gwd-animation-impl.js index 4ecf8144f70be..76218e23de304 100644 --- a/extensions/amp-gwd-animation/0.1/amp-gwd-animation-impl.js +++ b/extensions/amp-gwd-animation/0.1/amp-gwd-animation-impl.js @@ -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]; }