Repository navigation
feat(img): add ionError event - #17134
Conversation
| src={this.loadSrc} | ||
| alt={this.alt} | ||
| decoding="async" | ||
| onError={this.loadError} |
There was a problem hiding this comment.
wondering why we can't just use onError directly
There was a problem hiding this comment.
That error trigger even before the image start loading as there is no src.
There was a problem hiding this comment.
@pickfire I think manu means removing onError={this.loadError} and instead using the Listen decorator:
@Listen('error')
onImgError(ev: Event) {
// Your code from loadError
}
There was a problem hiding this comment.
I tested that but it does not seem to work.
/** Emitted when img failed to load */
@Event() ionError!: EventEmitter<void>;
@Listen('error')
onImgError() {
this.ionError.emit();
}
...
render() {
return (
<img
src={this.loadSrc}
alt={this.alt}
decoding="async"
// onError={this.loadError}
/>
);
}There was a problem hiding this comment.
I believe this is because the error event does not bubble: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror
|
Can this PR be merged? It's really blocking us because we can't implement a fallback image when image loading fails. I just want to know if I should put effort in migrating everything to a regular |
|
@SamVerschueren Same, it's blocking for us as well. I am not sure whether this PR has been merged yet though, Ionic pull requests are weird. |
| src={this.loadSrc} | ||
| alt={this.alt} | ||
| decoding="async" | ||
| onError={this.loadError} |
There was a problem hiding this comment.
I believe this is because the error event does not bubble: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror
|
@liamdebeasi Thanks a lot for merging this. 😄 |
closes #16947
Short description of what this resolves:
Propagate ionError event for img
Changes proposed in this pull request:
Ionic Version: 4.6.0
Fixes: #16947