Skip to content

Commit

Permalink
fix loadfailure error (google#3742)
Browse files Browse the repository at this point in the history
  • Loading branch information
elalish authored Aug 25, 2022
1 parent ebae7e3 commit d3ba177
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/model-viewer/src/model-viewer-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ export default class ModelViewerElementBase extends ReactiveElement {
const detail = {url: source};
this.dispatchEvent(new CustomEvent('preload', {detail}));
} catch (error) {
this.dispatchEvent(new CustomEvent('error', {detail: error}));
this.dispatchEvent(new CustomEvent(
'error', {detail: {type: 'loadfailure', sourceError: error}}));
} finally {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
Expand Down
4 changes: 3 additions & 1 deletion packages/model-viewer/src/test/model-viewer-base-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ suite('ModelViewerElementBase', () => {
test('eventually dispatches an error event', async () => {
const sourceErrors = waitForEvent(element, 'error');
element.src = './does-not-exist.glb';
await sourceErrors;
const event = await sourceErrors;

expect((event as any).detail.type).to.be.eq('loadfailure');
});
});

Expand Down

0 comments on commit d3ba177

Please sign in to comment.