@@ -12,6 +12,7 @@ import {
12
12
ViewStateSupport ,
13
13
} from '@ember/-internals/views' ;
14
14
import { assert } from '@ember/debug' ;
15
+ import { DEBUG } from '@glimmer/env' ;
15
16
import { DirtyableTag } from '@glimmer/reference' ;
16
17
import { normalizeProperty , SVG_NAMESPACE } from '@glimmer/runtime' ;
17
18
@@ -727,27 +728,26 @@ const Component = CoreView.extend(
727
728
this [ ROOT_REF ] = new RootReference ( this ) ;
728
729
this [ BOUNDS ] = null ;
729
730
730
- // If in a tagless component, assert that no event handlers are defined
731
- assert (
732
- // tslint:disable-next-line:max-line-length
733
- `You can not define a function that handles DOM events in the \`${ this } \` tagless component since it doesn't have any DOM element.` ,
734
- this . tagName !== '' ||
735
- ! this . renderer . _destinedForDOM ||
736
- ! ( ( ) => {
737
- let eventDispatcher = getOwner ( this ) . lookup < any | undefined > ( 'event_dispatcher:main' ) ;
738
- let events = ( eventDispatcher && eventDispatcher . _finalEvents ) || { } ;
739
-
740
- // tslint:disable-next-line:forin
741
- for ( let key in events ) {
742
- let methodName = events [ key ] ;
743
-
744
- if ( typeof this [ methodName ] === 'function' ) {
745
- return true ; // indicate that the assertion should be triggered
746
- }
747
- }
748
- return false ;
749
- } ) ( )
750
- ) ;
731
+ if ( DEBUG && this . renderer . _destinedForDOM && this . tagName === '' ) {
732
+ let eventNames = [ ] ;
733
+ let eventDispatcher = getOwner ( this ) . lookup < any | undefined > ( 'event_dispatcher:main' ) ;
734
+ let events = ( eventDispatcher && eventDispatcher . _finalEvents ) || { } ;
735
+
736
+ // tslint:disable-next-line:forin
737
+ for ( let key in events ) {
738
+ let methodName = events [ key ] ;
739
+
740
+ if ( typeof this [ methodName ] === 'function' ) {
741
+ eventNames . push ( methodName ) ;
742
+ }
743
+ }
744
+ // If in a tagless component, assert that no event handlers are defined
745
+ assert (
746
+ // tslint:disable-next-line:max-line-length
747
+ `You can not define \`${ eventNames } \` function(s) to handle DOM event in the \`${ this } \` tagless component since it doesn't have any DOM element.` ,
748
+ ! eventNames . length
749
+ ) ;
750
+ }
751
751
} ,
752
752
753
753
rerender ( ) {
0 commit comments