Fix amp img lightbox#5279
Conversation
|
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. |
|
Would be neat to have a test, of course. Does this need to be merged into canary or even prod? |
71b210e to
b71025a
Compare
|
CLAs look good, thanks! |
|
@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) |
|
also yeah, it is probably a good idea to cherry pick this into production |
|
@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) |
|
and also wanted to get fix in for #5280 |
|
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 |
b71025a to
1125d36
Compare
| // 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_); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
yep thats a good idea 👍, this (loadPromise) probably should have been a static method instead of an instance method
There was a problem hiding this comment.
Also just noticed that amp-image-lightbox imports isLoaded from event-helper.
Other files seem to import from event-helper as well.
There was a problem hiding this comment.
@mkhatib that's definitely another candidate that can be moved over to BaseElement
There was a problem hiding this comment.
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_); |
There was a problem hiding this comment.
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.
* ImageViewer class does not inherit `loadPromise` * add simple test * bind the function passed in since it is an instance method
* ImageViewer class does not inherit `loadPromise` * add simple test * bind the function passed in since it is an instance method
* ImageViewer class does not inherit `loadPromise` * add simple test * bind the function passed in since it is an instance method
* ImageViewer class does not inherit `loadPromise` * add simple test * bind the function passed in since it is an instance method
* ImageViewer class does not inherit `loadPromise` * add simple test * bind the function passed in since it is an instance method
fixes #5278
ImageViewer does not extend
BaseElementthere does not havethis.loadPromise