Skip to content

Commit

Permalink
Remove extra getLayoutWidth call
Browse files Browse the repository at this point in the history
  • Loading branch information
cathyxz committed Feb 26, 2019
1 parent fc2a44e commit ad83b0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builtins/amp-img.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,21 @@ export class AmpImg extends BaseElement {
}
const generatedSizes = entry + defaultSize;

if (this.shouldSetSizes_()) {
if (this.shouldSetSizes_(width)) {
this.img_.setAttribute('sizes', generatedSizes);
this.sizesWidth_ = width;
}
}

/**
* @param {number} newWidth
* @private
*/
shouldSetSizes_() {
shouldSetSizes_(newWidth) {
if (!this.img_.hasAttribute('sizes')) {
return true;
}

return this.getLayoutWidth() > this.sizesWidth_;
return newWidth > this.sizesWidth_;
}

/** @override */
Expand Down

0 comments on commit ad83b0d

Please sign in to comment.