diff --git a/projects/flosportsinc/ng-fullscreen/karma.conf.js b/projects/flosportsinc/ng-fullscreen/karma.conf.js index 7f753cd7..58f1709b 100644 --- a/projects/flosportsinc/ng-fullscreen/karma.conf.js +++ b/projects/flosportsinc/ng-fullscreen/karma.conf.js @@ -2,6 +2,6 @@ const config = require('../../../src/karma.conf.shared') module.exports = config('../coverage/ng-fullscreen')()({ statements: 97, lines: 98, - branches: 86, + branches: 85, functions: 93 }) diff --git a/projects/flosportsinc/ng-fullscreen/src/common/ng-fullscreen.service.ts b/projects/flosportsinc/ng-fullscreen/src/common/ng-fullscreen.service.ts index 8ba62f6f..614ed1a1 100644 --- a/projects/flosportsinc/ng-fullscreen/src/common/ng-fullscreen.service.ts +++ b/projects/flosportsinc/ng-fullscreen/src/common/ng-fullscreen.service.ts @@ -1,3 +1,5 @@ + +import { isIphone } from './util' import { DOCUMENT, isPlatformServer } from '@angular/common' import { Injectable, Inject, PLATFORM_ID } from '@angular/core' import { merge, fromEvent, Observable, throwError, of, interval, BehaviorSubject, EMPTY } from 'rxjs' @@ -9,7 +11,6 @@ import { FS_FULLSCREEN_ENABLED, FullscreenEnabledKeys, FS_FULLSCREEN_ENABLED_FUNC, FullscreenEnabledFunc, FS_FULLSCREEN_IOS_POLL_MS, FS_FULLSCREEN_IOS_POLL_ENABLED } from './ng-fullscreen.tokens' -import { isIphone } from './util' const isKeyTrue = (platformKeys: ReadonlyArray) => @@ -23,9 +24,13 @@ const fullscreenChangeError = const filterAndExecute = (ref: HTMLElement | HTMLDocument) => - (arr: ReadonlyArray) => arr - .filter(a => typeof ref[a] === 'function') - .forEach(a => ref[a]()) + (arr: ReadonlyArray) => { + const funcStringIdx = arr.findIndex(a => typeof ref[a] === 'function') + // tslint:disable-next-line: no-if-statement + if (funcStringIdx >= 0) { + ref[arr[funcStringIdx]]() + } + } export interface IFloFullscreenService { readonly fullscreen$: Observable