Skip to content

Commit

Permalink
Fix for a null pointer in the image viewer.
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Mar 10, 2016
1 parent 05cbae8 commit 01cdee7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/domutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ export function getShadowRoot(self: HTMLElement): ShadowRoot {
}

export function getShadowId(el: HTMLElement, id: string): HTMLElement {
return <HTMLElement> getShadowRoot(el).querySelector('#' + id);
const shadowRoot = getShadowRoot(el);
if (shadowRoot === null) {
return null;
}
return <HTMLElement> shadowRoot.querySelector('#' + id);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/viewers/imageviewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ class EtImageViewer extends ViewerElement {
this._adjustHeight(setterState.height);

const containerDiv = domutils.getShadowId(this, ID_CONTAINER);
containerDiv.scrollTop = setterState.yOffset;
if (containerDiv !== null) {
containerDiv.scrollTop = setterState.yOffset;
}
}
}

Expand Down

0 comments on commit 01cdee7

Please sign in to comment.