@@ -20,7 +20,7 @@ export function clearNode(node: HTMLElement): void {
2020 }
2121}
2222
23- export function isInDOM ( node : Node ) : boolean {
23+ export function isInDOM ( node : Node | null ) : boolean {
2424 while ( node ) {
2525 if ( node === document . body ) {
2626 return true ;
@@ -151,7 +151,7 @@ const _manualClassList = new class implements IDomClassList {
151151
152152const _nativeClassList = new class implements IDomClassList {
153153 hasClass ( node : HTMLElement , className : string ) : boolean {
154- return className && node . classList && node . classList . contains ( className ) ;
154+ return Boolean ( className ) && node . classList && node . classList . contains ( className ) ;
155155 }
156156
157157 addClasses ( node : HTMLElement , ...classNames : string [ ] ) : void {
@@ -198,7 +198,7 @@ class DomListener implements IDisposable {
198198 private readonly _type : string ;
199199 private readonly _useCapture : boolean ;
200200
201- constructor ( node : Element | Window | Document , type : string , handler : ( e : any ) => void , useCapture : boolean ) {
201+ constructor ( node : Element | Window | Document , type : string , handler : ( e : any ) => void , useCapture ? : boolean ) {
202202 this . _node = node ;
203203 this . _type = type ;
204204 this . _handler = handler ;
@@ -215,8 +215,8 @@ class DomListener implements IDisposable {
215215 this . _node . removeEventListener ( this . _type , this . _handler , this . _useCapture ) ;
216216
217217 // Prevent leakers from holding on to the dom or handler func
218- this . _node = null ;
219- this . _handler = null ;
218+ this . _node = null ! ;
219+ this . _handler = null ! ;
220220 }
221221}
222222
@@ -257,7 +257,7 @@ export let addStandardDisposableListener: IAddStandardDisposableListenerSignatur
257257export function addDisposableNonBubblingMouseOutListener ( node : Element , handler : ( event : MouseEvent ) => void ) : IDisposable {
258258 return addDisposableListener ( node , 'mouseout' , ( e : MouseEvent ) => {
259259 // Mouse out bubbles, so this is an attempt to ignore faux mouse outs coming from children elements
260- let toElement = < Node > ( e . relatedTarget || e . toElement ) ;
260+ let toElement : Node | null = < Node > ( e . relatedTarget || e . toElement ) ;
261261 while ( toElement && toElement !== node ) {
262262 toElement = toElement . parentNode ;
263263 }
@@ -311,7 +311,7 @@ class AnimationFrameQueueItem implements IDisposable {
311311 public priority : number ;
312312 private _canceled : boolean ;
313313
314- constructor ( runner : ( ) => void , priority : number ) {
314+ constructor ( runner : ( ) => void , priority : number = 0 ) {
315315 this . _runner = runner ;
316316 this . priority = priority ;
317317 this . _canceled = false ;
@@ -366,7 +366,7 @@ class AnimationFrameQueueItem implements IDisposable {
366366 inAnimationFrameRunner = true ;
367367 while ( CURRENT_QUEUE . length > 0 ) {
368368 CURRENT_QUEUE . sort ( AnimationFrameQueueItem . sort ) ;
369- let top = CURRENT_QUEUE . shift ( ) ;
369+ let top = CURRENT_QUEUE . shift ( ) ! ;
370370 top . execute ( ) ;
371371 }
372372 inAnimationFrameRunner = false ;
@@ -387,7 +387,7 @@ class AnimationFrameQueueItem implements IDisposable {
387387 runAtThisOrScheduleAtNextAnimationFrame = ( runner : ( ) => void , priority ?: number ) => {
388388 if ( inAnimationFrameRunner ) {
389389 let item = new AnimationFrameQueueItem ( runner , priority ) ;
390- CURRENT_QUEUE . push ( item ) ;
390+ CURRENT_QUEUE ! . push ( item ) ;
391391 return item ;
392392 } else {
393393 return scheduleAtNextAnimationFrame ( runner , priority ) ;
@@ -407,7 +407,7 @@ export function modify(callback: () => void): IDisposable {
407407 * Add a throttled listener. `handler` is fired at most every 16ms or with the next animation frame (if browser supports it).
408408 */
409409export interface IEventMerger < R , E > {
410- ( lastEvent : R , currentEvent : E ) : R ;
410+ ( lastEvent : R | null , currentEvent : E ) : R ;
411411}
412412
413413export interface DOMEvent {
@@ -431,7 +431,7 @@ class TimeoutThrottledDomListener<R, E extends DOMEvent> extends Disposable {
431431
432432 let invokeHandler = ( ) => {
433433 lastHandlerTime = ( new Date ( ) ) . getTime ( ) ;
434- handler ( lastEvent ) ;
434+ handler ( < R > lastEvent ) ;
435435 lastEvent = null ;
436436 } ;
437437
@@ -455,7 +455,7 @@ export function addDisposableThrottledListener<R, E extends DOMEvent = DOMEvent>
455455}
456456
457457export function getComputedStyle ( el : HTMLElement ) : CSSStyleDeclaration {
458- return document . defaultView . getComputedStyle ( el , null ) ;
458+ return document . defaultView ! . getComputedStyle ( el , null ) ;
459459}
460460
461461// Adapted from WinJS
@@ -660,7 +660,7 @@ export const StandardWindow: IStandardWindow = new class implements IStandardWin
660660 // modern browsers
661661 return window . scrollX ;
662662 } else {
663- return document . body . scrollLeft + document . documentElement . scrollLeft ;
663+ return document . body . scrollLeft + document . documentElement ! . scrollLeft ;
664664 }
665665 }
666666
@@ -669,7 +669,7 @@ export const StandardWindow: IStandardWindow = new class implements IStandardWin
669669 // modern browsers
670670 return window . scrollY ;
671671 } else {
672- return document . body . scrollTop + document . documentElement . scrollTop ;
672+ return document . body . scrollTop + document . documentElement ! . scrollTop ;
673673 }
674674 }
675675} ;
@@ -728,7 +728,7 @@ export function getLargestChildWidth(parent: HTMLElement, children: HTMLElement[
728728
729729// ----------------------------------------------------------------------------------------
730730
731- export function isAncestor ( testChild : Node , testAncestor : Node ) : boolean {
731+ export function isAncestor ( testChild : Node | null , testAncestor : Node ) : boolean {
732732 while ( testChild ) {
733733 if ( testChild === testAncestor ) {
734734 return true ;
@@ -739,7 +739,7 @@ export function isAncestor(testChild: Node, testAncestor: Node): boolean {
739739 return false ;
740740}
741741
742- export function findParentWithClass ( node : HTMLElement , clazz : string , stopAtClazzOrNode ?: string | HTMLElement ) : HTMLElement {
742+ export function findParentWithClass ( node : HTMLElement , clazz : string , stopAtClazzOrNode ?: string | HTMLElement ) : HTMLElement | null {
743743 while ( node ) {
744744 if ( hasClass ( node , clazz ) ) {
745745 return node ;
@@ -1002,17 +1002,18 @@ export function $<T extends HTMLElement>(description: string, attrs?: { [key: st
10021002 result . className = match [ 4 ] . replace ( / \. / g, ' ' ) . trim ( ) ;
10031003 }
10041004
1005- Object . keys ( attrs || { } ) . forEach ( name => {
1005+ attrs = attrs || { } ;
1006+ Object . keys ( attrs ) . forEach ( name => {
1007+ const value = attrs ! [ name ] ;
10061008 if ( / ^ o n \w + $ / . test ( name ) ) {
1007- ( < any > result ) [ name ] = attrs [ name ] ;
1009+ ( < any > result ) [ name ] = value ;
10081010 } else if ( name === 'selected' ) {
1009- const value = attrs [ name ] ;
10101011 if ( value ) {
10111012 result . setAttribute ( name , 'true' ) ;
10121013 }
10131014
10141015 } else {
1015- result . setAttribute ( name , attrs [ name ] ) ;
1016+ result . setAttribute ( name , value ) ;
10161017 }
10171018 } ) ;
10181019
@@ -1061,7 +1062,7 @@ export function hide(...elements: HTMLElement[]): void {
10611062 }
10621063}
10631064
1064- function findParentWithAttribute ( node : Node , attribute : string ) : HTMLElement {
1065+ function findParentWithAttribute ( node : Node | null , attribute : string ) : HTMLElement | null {
10651066 while ( node ) {
10661067 if ( node instanceof HTMLElement && node . hasAttribute ( attribute ) ) {
10671068 return node ;
0 commit comments