Permalink
Browse files

fix(dialog-renderer): lazy DOM access fix #294

  • Loading branch information...
StrahilKazlachev committed Jun 25, 2017
1 parent e90a9d8 commit f71ecf8cacb5ee1ff9f104d866b9fdf3cc90e5ef
Showing with 13 additions and 7 deletions.
  1. +13 −7 src/dialog-renderer.ts
View
@@ -30,22 +30,25 @@ export const transitionEvent = (() => {
export const hasTransition = (() => {
const unprefixedName: any = 'transitionDuration';
const el = DOM.createElement('fakeelement') as HTMLElement;
const prefixedNames = ['webkitTransitionDuration', 'oTransitionDuration'];
let el: HTMLElement;
let transitionDurationName: string | undefined;
if (unprefixedName in el.style) {
transitionDurationName = unprefixedName;
} else {
transitionDurationName = prefixedNames.find(prefixed => (prefixed in el.style));
}
return (element: Element) => {
if (!el) {
el = DOM.createElement('fakeelement') as HTMLElement;
if (unprefixedName in el.style) {
transitionDurationName = unprefixedName;
} else {
transitionDurationName = prefixedNames.find(prefixed => (prefixed in el.style));
}
}
return !!transitionDurationName && !!((DOM.getComputedStyle(element) as any)[transitionDurationName]
.split(',')
.find((duration: string) => !!parseFloat(duration)));
};
})();
const body = DOM.querySelectorAll('body')[0] as HTMLBodyElement;
let body: HTMLBodyElement;
function getActionKey(e: KeyboardEvent): ActionKey | undefined {
if ((e.code || e.key) === 'Escape' || e.keyCode === 27) {
@@ -202,6 +205,9 @@ export class DialogRenderer implements Renderer {
}
public showDialog(dialogController: DialogController): Promise<void> {
if (!body) {
body = DOM.querySelectorAll('body')[0] as HTMLBodyElement;
}
if (dialogController.settings.host) {
this.host = dialogController.settings.host;
} else {

0 comments on commit f71ecf8

Please sign in to comment.