mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
#960 fix event handling for FF
- use cross browser `event.target` instead of IE-specific `event.srcElement`
This commit is contained in:
@@ -314,26 +314,26 @@ describe('DataTable', () => {
|
||||
|
||||
it('should replace image source with fallback thumbnail on error', () => {
|
||||
let event = <any> {
|
||||
srcElement: {
|
||||
target: {
|
||||
src: 'missing-image'
|
||||
}
|
||||
};
|
||||
|
||||
dataTable.fallbackThumbnail = '<fallback>';
|
||||
dataTable.onImageLoadingError(event);
|
||||
expect(event.srcElement.src).toBe(dataTable.fallbackThumbnail);
|
||||
expect(event.target.src).toBe(dataTable.fallbackThumbnail);
|
||||
});
|
||||
|
||||
it('should replace image source only when fallback available', () => {
|
||||
const originalSrc = 'missing-image';
|
||||
let event = <any> {
|
||||
srcElement: {
|
||||
target: {
|
||||
src: originalSrc
|
||||
}
|
||||
};
|
||||
|
||||
dataTable.fallbackThumbnail = null;
|
||||
dataTable.onImageLoadingError(event);
|
||||
expect(event.srcElement.src).toBe(originalSrc);
|
||||
expect(event.target.src).toBe(originalSrc);
|
||||
});
|
||||
});
|
||||
|
@@ -146,7 +146,7 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
|
||||
|
||||
onImageLoadingError(event: Event) {
|
||||
if (event && this.fallbackThumbnail) {
|
||||
let element = <any> event.srcElement;
|
||||
let element = <any> event.target;
|
||||
element.src = this.fallbackThumbnail;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user