1
1
import PseudoEvents from '@ui5/webcomponents-core/dist/sap/ui/events/PseudoEvents' ;
2
2
import ControlEvents from './events/ControlEvents' ;
3
+ import WebComponent from './WebComponent' ;
3
4
4
5
const handleEvent = function ( event ) {
5
6
@@ -32,32 +33,24 @@ const getDomTarget = function(event) {
32
33
} ;
33
34
34
35
const processDOMNode = function ( node , event ) {
35
- const id = node . getAttribute ( "data-sap-ui" ) ;
36
- const tag = node . tagName ;
37
- let control ;
38
-
39
- if ( tag . match ( / ^ u i 5 - / i) ) {
40
- control = node ;
41
- }
42
-
43
- if ( control && control . _handleEvent ) {
44
- return dispatchEvent ( control , event ) ;
36
+ if ( node && node instanceof WebComponent ) {
37
+ return dispatchEvent ( node , event ) ;
45
38
}
46
39
return true ;
47
40
} ;
48
41
49
- const dispatchEvent = function ( control , event ) {
42
+ const dispatchEvent = function ( ui5WebComponent , event ) {
50
43
51
44
// Handle the original event (such as "keydown")
52
- control . _handleEvent ( event ) ;
45
+ ui5WebComponent . _handleEvent ( event ) ;
53
46
if ( event . isImmediatePropagationStopped ( ) ) {
54
47
return false ;
55
48
}
56
49
57
50
// Handle pseudo events that derive from the original event (such as "sapselect")
58
51
const pseudoTypes = getPseudoTypesFor ( event ) ;
59
52
for ( let i = 0 , len = pseudoTypes . length ; i < len ; i ++ ) {
60
- control . _handleEvent ( event , pseudoTypes [ i ] ) ;
53
+ ui5WebComponent . _handleEvent ( event , pseudoTypes [ i ] ) ;
61
54
if ( event . isImmediatePropagationStopped ( ) ) {
62
55
return false ;
63
56
}
@@ -104,8 +97,6 @@ const getPseudoTypesFor = function(event) {
104
97
const getParentDOMNode = function ( node ) {
105
98
const parentNode = node . parentNode ;
106
99
107
- // Skip the custom element tag (host) only if crossing a shadow DOM boundary
108
- // The reason is that the event was already dispatched to the light control while traversing the shadow DOM
109
100
if ( parentNode && parentNode . host ) {
110
101
return parentNode . host ;
111
102
}
@@ -129,4 +120,4 @@ class DOMEventHandler {
129
120
}
130
121
131
122
132
- export default DOMEventHandler ;
123
+ export default DOMEventHandler ;
0 commit comments