Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix amp img lightbox#5279

Merged
erwinmombay merged 3 commits into
ampproject:masterfrom
erwinmombay:fix-amp-img-lightbox
Sep 28, 2016
Merged

Fix amp img lightbox#5279
erwinmombay merged 3 commits into
ampproject:masterfrom
erwinmombay:fix-amp-img-lightbox

Conversation

@erwinmombay

Copy link
Copy Markdown
Member

fixes #5278

ImageViewer does not extend BaseElement there does not have this.loadPromise

@googlebot

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@cramforce

Copy link
Copy Markdown
Member

Would be neat to have a test, of course. Does this need to be merged into canary or even prod?
@mkhatib's commit somehow leaked into this PR.

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

@erwinmombay

Copy link
Copy Markdown
Member Author

@cramforce fixed commit issue. I was planning on adding a test but thought I'd just turn on the type check for the component which would also catch this. (Will do another round of type check runs on some components)

@erwinmombay

Copy link
Copy Markdown
Member Author

also yeah, it is probably a good idea to cherry pick this into production

@erwinmombay

Copy link
Copy Markdown
Member Author

@cramforce for the patching part, you ok with doing it after regular release tomorrow morning? I'm writing down docs for it and good for me to do + write down docs same time (a bit of a selfish ask lol)

@erwinmombay

Copy link
Copy Markdown
Member Author

and also wanted to get fix in for #5280

@erwinmombay

Copy link
Copy Markdown
Member Author

just checked this is currently only in canary so best to cherry pick this asap before tomorrow's prod promote. ill get this in once approve

// and then naturally upgrade to a higher quality image.
return timerFor(this.win).promise(1).then(() => {
this.image_.setAttribute('src', src);
return this.loadPromise(this.image_);

@mkhatib mkhatib Sep 28, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so BaseElement.loadPromise seems to be basically a call to event-helper.loadPromise. Can't we just import that and use that instead of passing it around?

I realize BaseElement.loadPromise might change, but this call might cause problems the context it's being called with, so if we want to keep this we might need to bind it to the AmpImageLightbox before calling it otherwise it might break in the future.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

if we import it directly that will mean the loadPromise implementation as well as its dependency inside that module will then be compiled into the amp-image-lightbox.js binary. The reason the delegation was done was so that the loadPromise code and event-helper.js code is only inside the v0.js binary and not inside extensions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see thanks for explaining. Should we then bind the this.loadPromise.bind(this) and pass it to make sure the context is transferred.

I am cool with this either way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yep thats a good idea 👍, this (loadPromise) probably should have been a static method instead of an instance method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also just noticed that amp-image-lightbox imports isLoaded from event-helper.

Other files seem to import from event-helper as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mkhatib that's definitely another candidate that can be moved over to BaseElement

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

although with how small that function is, might not be worth it. we'll see

// and then naturally upgrade to a higher quality image.
return timerFor(this.win).promise(1).then(() => {
this.image_.setAttribute('src', src);
return this.loadPromise(this.image_);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see thanks for explaining. Should we then bind the this.loadPromise.bind(this) and pass it to make sure the context is transferred.

I am cool with this either way.

@erwinmombay erwinmombay merged commit 565b579 into ampproject:master Sep 28, 2016
erwinmombay added a commit that referenced this pull request Sep 28, 2016
* ImageViewer class does not inherit `loadPromise`

* add simple test

* bind the function passed in since it is an instance method
dreamofabear pushed a commit to dreamofabear/amphtml that referenced this pull request Oct 4, 2016
* ImageViewer class does not inherit `loadPromise`

* add simple test

* bind the function passed in since it is an instance method
Lith pushed a commit to Lith/amphtml that referenced this pull request Oct 5, 2016
* ImageViewer class does not inherit `loadPromise`

* add simple test

* bind the function passed in since it is an instance method
dreamofabear pushed a commit to dreamofabear/amphtml that referenced this pull request Oct 12, 2016
* ImageViewer class does not inherit `loadPromise`

* add simple test

* bind the function passed in since it is an instance method
mityaha pushed a commit to brightcove-archive/ooyala_amphtml that referenced this pull request Nov 30, 2016
* ImageViewer class does not inherit `loadPromise`

* add simple test

* bind the function passed in since it is an instance method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: a.loadPromise is not a function in amp-image-lightbox

4 participants