refactor(all): strict boolean conditions

This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
Manu Mtz.-Almeida
2018-08-31 18:59:09 +02:00
gitea-unlock(16/)
parent f383ebdf13
commit ba2230510e
octicon-diff(16/tw-mr-1) 96 changed files with 990 additions and 962 deletions

6
core/src/utils/input-shims/hacks/hide-caret.ts
View File

@@ -17,10 +17,8 @@ export function enableHideCaretOnScroll(componentEl: HTMLElement, inputEl: HTMLI
const hideCaret = () => scrollHideCaret(true);
const showCaret = () => scrollHideCaret(false);
if (scrollEl) {
scrollEl.addEventListener('ionScrollStart', hideCaret);
scrollEl.addEventListener('ionScrollEnd', showCaret);
}
scrollEl.addEventListener('ionScrollStart', hideCaret);
scrollEl.addEventListener('ionScrollEnd', showCaret);
inputEl.addEventListener('blur', onBlur);
return () => {

2
core/src/utils/input-shims/hacks/input-blurring.ts
View File

@@ -21,7 +21,7 @@ export function enableInputBlurring(doc: Document) {
didScroll = false;
return;
}
const active = doc.activeElement as HTMLElement;
const active = doc.activeElement as HTMLElement | null;
if (!active) {
return;
}

1
core/src/utils/input-shims/hacks/scroll-assist.ts
View File

@@ -64,6 +64,7 @@ function jsSetFocus(
inputEl.focus();
// scroll the input into place
// tslint:disable-next-line:no-floating-promises
contentEl.scrollByPoint(0, scrollData.scrollAmount, scrollData.scrollDuration).then(() => {
// the scroll view is in the correct position now
// give the native text input focus

9
core/src/utils/input-shims/hacks/scroll-data.ts
View File

@@ -9,15 +9,6 @@ export interface ScrollData {
}
export function getScrollData(componentEl: HTMLElement, contentEl: HTMLElement, keyboardHeight: number): ScrollData {
if (!contentEl) {
return {
scrollAmount: 0,
scrollPadding: 0,
scrollDuration: 0,
inputSafeY: 0,
};
}
const itemEl = componentEl.closest('ion-item,[ion-item]') as HTMLElement || componentEl;
return calcScrollData(
itemEl.getBoundingClientRect(),

4
core/src/utils/input-shims/hacks/scroll-padding.ts
View File

@@ -26,8 +26,8 @@ function setScrollPadding(input: HTMLElement, keyboardHeight: number) {
if (input.parentElement && input.parentElement.tagName === 'ION-INPUT') {
return;
}
const el = input.closest('ion-content') as HTMLElement;
if (!el) {
const el = input.closest('ion-content');
if (el === null) {
return;
}
const timer = (el as any)[PADDING_TIMER_KEY];

4
core/src/utils/input-shims/input-shims.ts
View File

@@ -32,12 +32,12 @@ export function startInputShims(
return;
}
if (HIDE_CARET && scrollEl && hideCaret && !hideCaretMap.has(componentEl)) {
if (HIDE_CARET && !!scrollEl && hideCaret && !hideCaretMap.has(componentEl)) {
const rmFn = enableHideCaretOnScroll(componentEl, inputEl, scrollEl);
hideCaretMap.set(componentEl, rmFn);
}
if (SCROLL_ASSIST && scrollEl && scrollAssist && !scrollAssistMap.has(componentEl)) {
if (SCROLL_ASSIST && !!scrollEl && scrollAssist && !scrollAssistMap.has(componentEl)) {
const rmFn = enableScrollAssist(componentEl, inputEl, scrollEl, keyboardHeight);
scrollAssistMap.set(componentEl, rmFn);
}