chore(types): add null checks (#16351)

This commit is contained in:
Adam Bradley
2018-11-16 22:20:51 -06:00
committed by GitHub
parent 2e8f15af18
commit 8cb266ba34
5 changed files with 10 additions and 8 deletions

View File

@ -160,12 +160,14 @@ export class Router implements ComponentInterface {
}
private historyDirection() {
if (this.win.history.state === null) {
const win = this.win;
if (win.history.state === null) {
this.state++;
this.win.history.replaceState(this.state, this.win.document.title, this.win.document.location.href);
win.history.replaceState(this.state, win.document.title, win.document.location && win.document.location.href);
}
const state = this.win.history.state;
const state = win.history.state;
const lastState = this.lastState;
this.lastState = state;

View File

@ -112,8 +112,8 @@ export class SplitPane implements ComponentInterface {
this.visible = q.matches;
};
const mediaList = this.win.matchMedia(mediaQuery);
mediaList.addListener(callback);
this.rmL = () => mediaList.removeListener(callback);
mediaList.addListener(callback as any);
this.rmL = () => mediaList.removeListener(callback as any);
this.visible = mediaList.matches;
}

View File

@ -124,7 +124,7 @@ export function doRender(
function createNode(el: HTMLElement, type: CellType): HTMLElement | null {
const template = getTemplate(el, type);
if (template) {
if (template && el.ownerDocument) {
return el.ownerDocument.importNode(template.content, true).children[0] as HTMLElement;
}
return null;

View File

@ -15,7 +15,7 @@ export async function attachComponent(
}
const el: any = (typeof component === 'string')
? container.ownerDocument.createElement(component)
? container.ownerDocument && container.ownerDocument.createElement(component)
: component;
if (cssClasses) {

View File

@ -1,7 +1,7 @@
export function isTextInputFocused(doc: Document): boolean {
const activeElement = doc.activeElement;
if (isTextInput(activeElement) && activeElement.parentElement) {
if (activeElement && isTextInput(activeElement) && activeElement.parentElement) {
return activeElement.parentElement.querySelector(':focus') === activeElement;
}
return false;