@@ -35,12 +35,12 @@ export class DeluxeSignal extends PrioritySignal {
3535 */
3636 constructor ( target : Object = null , ...valueClasses ) {
3737 // Cannot use super.apply(null, valueClasses), so allow the subclass to call super(valueClasses).
38- valueClasses = ( valueClasses . length == 1 && valueClasses [ 0 ] instanceof Array ) ? valueClasses [ 0 ] : valueClasses ;
38+ valueClasses = ( valueClasses . length === 1 && valueClasses [ 0 ] instanceof Array ) ? valueClasses [ 0 ] : valueClasses ;
3939
4040 super ( valueClasses ) ;
4141
42- //@CHANGED - this was the first call in the constructor
43- //Typescript does not allow "this" to be called before super
42+ // @CHANGED - this was the first call in the constructor
43+ // Typescript does not allow "this" to be called before super
4444 this . _target = target ;
4545 }
4646
@@ -50,7 +50,9 @@ export class DeluxeSignal extends PrioritySignal {
5050 }
5151
5252 public set target ( value : Object ) {
53- if ( value == this . _target ) return ;
53+ if ( value === this . _target ) {
54+ return ;
55+ }
5456 this . removeAll ( ) ;
5557 this . _target = value ;
5658 }
@@ -63,27 +65,32 @@ export class DeluxeSignal extends PrioritySignal {
6365 /*override*/
6466 public dispatch ( ...valueObjects ) : void {
6567 // Validate value objects against pre-defined value classes.
66- var numValueClasses : number = this . _valueClasses . length ;
67- var numValueObjects : number = valueObjects . length ;
68+ let numValueClasses : number = this . _valueClasses . length ;
69+ let numValueObjects : number = valueObjects . length ;
6870
6971 if ( numValueObjects < numValueClasses ) {
70- throw new Error ( 'Incorrect number of arguments. ' +
71- 'Expected at least ' + numValueClasses + ' but received ' +
72- numValueObjects + '.' ) ;
72+ throw new Error (
73+ "Incorrect number of arguments. " +
74+ "Expected at least " + numValueClasses + " but received " +
75+ numValueObjects + "."
76+ ) ;
7377 }
7478
7579 // Cannot dispatch differently typed objects than declared classes.
76- for ( var i : number = 0 ; i < numValueClasses ; i ++ ) {
80+ for ( let i : number = 0 ; i < numValueClasses ; i ++ ) {
7781 // Optimized for the optimistic case that values are correct.
78- if ( valueObjects [ i ] === null || valueObjects [ i ] . constructor === this . _valueClasses [ i ] )
82+ if ( valueObjects [ i ] === null || valueObjects [ i ] . constructor === this . _valueClasses [ i ] ) {
7983 continue ;
84+ }
8085
81- throw new Error ( 'Value object <' + valueObjects [ i ]
82- + '> is not an instance of <' + this . _valueClasses [ i ] + '>.' ) ;
86+ throw new Error (
87+ "Value object <" + valueObjects [ i ] +
88+ "> is not an instance of <" + this . _valueClasses [ i ] + ">."
89+ ) ;
8390 }
8491
8592 // Extract and clone event object if necessary.
86- var event : IEvent = ( < IEvent > valueObjects [ 0 ] ) ;
93+ let event : IEvent = ( < IEvent > valueObjects [ 0 ] ) ;
8794 if ( event ) {
8895 if ( event . target ) {
8996 event = event . clone ( ) ;
@@ -96,29 +103,34 @@ export class DeluxeSignal extends PrioritySignal {
96103 }
97104
98105 // Broadcast to listeners.
99- var slotsToProcess : SlotList = this . slots ;
106+ let slotsToProcess : SlotList = this . slots ;
100107 while ( slotsToProcess . nonEmpty ) {
101108 slotsToProcess . head . execute ( valueObjects ) ;
102109 slotsToProcess = slotsToProcess . tail ;
103110 }
104111
105112 // Bubble the event as far as possible.
106- if ( ! event || ! event . bubbles ) return ;
113+ if ( ! event || ! event . bubbles ) {
114+ return ;
115+ }
107116
108- var currentTarget : Object = this . target ;
117+ let currentTarget : Object = this . target ;
109118
110119 while ( currentTarget && currentTarget . hasOwnProperty ( "parent" ) ) {
111- currentTarget = currentTarget [ "parent" ] ;
112- if ( ! currentTarget ) break ;
120+ currentTarget = ( < any > currentTarget ) . parent ;
121+
122+ if ( ! currentTarget ) {
123+ break ;
124+ }
113125
114- if ( ( < IBubbleEventHandler > currentTarget ) . onEventBubbled !== undefined ) {
126+ if ( ( < any > currentTarget ) . onEventBubbled !== null ) {
115127 event . currentTarget = currentTarget ;
128+
116129 // onEventBubbled() can stop the bubbling by returning false.
117- if ( ( < IBubbleEventHandler > currentTarget ) . onEventBubbled ( event ) )
130+ if ( ! ( < any > currentTarget ) . onEventBubbled ( event ) ) {
118131 break ;
132+ }
119133 }
120134 }
121135 }
122-
123136}
124-
0 commit comments