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

Move extractSize to a separate hook #10127

Merged
merged 6 commits into from Jun 28, 2017
Merged

Move extractSize to a separate hook #10127

merged 6 commits into from Jun 28, 2017

Conversation

taymonbeal
Copy link
Member

Determining the size of a Fast Fetch creative is now done through its own overridable method in AmpA4A. This will facilitate the deprecation of extractCreativeAndSignature, which in turn will facilitate having two different signature schemes controlled by a client-side experiment.

One of the PRs that #9040 is being split into. Related to #7618.

.then(adResponse => {
expect(adResponse).to.deep.equal(
{creative, signature: base64UrlDecodeToBytes('AQAB')});
expect(impl.extractSize(headers)).to.deep.equal(size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: indent is off here.

@@ -649,20 +654,23 @@ export class AmpA4A extends AMP.BaseElement {
// This block returns the ad creative and signature, if available; null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update these comments to reflect that size will also be passed down through here.

expect(loadExtensionSpy.withArgs('amp-analytics')).to.be.called;
signature: base64UrlDecodeToBytes('AQAB'),
});
expect(impl.extractSize(headers)).to.deep.equal(size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: indent here as well.

if (!headerValue) {
return null;
}
if (!(/[0-9]+x[0-9]+/.test(headerValue))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to do a RegExp, why not just capture the values out of the regexp and save the split?

if (size) {
this.size_ = size;
} else {
size = this.size_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always felt odd to me. Why not have this return null if its not in the headers and move the logic to when we apply sizing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be honest, I don't really understand how this code works. Do you mean the call to setStyles in onCreativeRender? Where would that code get the information about what size to use, if it wasn't set here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK no need to address in this PR.

if (size) {
this.size_ = size;
} else {
size = this.size_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK no need to address in this PR.

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

Successfully merging this pull request may close these issues.

None yet

4 participants