8
0
Эх сурвалжийг харах

Add comment explaining composedPath undefined check

yanasang 5 жил өмнө
parent
commit
d30bcd7295

+ 4 - 2
packages/ckeditor5-ui/src/bindings/clickoutsidehandler.js

@@ -30,9 +30,11 @@ export default function clickOutsideHandler( { emitter, activator, callback, con
 			return;
 			return;
 		}
 		}
 
 
+		// Check if composedPath is undefined in case the browser does not support native shadow DOM
+		// Can be removed when all supported browsers support native shadow DOM
+		const path = domEvt.composedPath !== undefined ? domEvt.composedPath() : [];
 		for ( const contextElement of contextElements ) {
 		for ( const contextElement of contextElements ) {
-			if ( contextElement.contains( domEvt.target ) ||
-						( 'composedPath' in domEvt && domEvt.composedPath().includes( contextElement ) ) ) {
+			if ( contextElement.contains( domEvt.target ) || path.includes( contextElement ) ) {
 				return;
 				return;
 			}
 			}
 		}
 		}