1- import { IS_NON_DIMENSIONAL } from '../constants' ;
1+ import { IS_NON_DIMENSIONAL , SVG_NAMESPACE } from '../constants' ;
22import options from '../options' ;
33
44function setStyle ( style , key , value ) {
@@ -13,6 +13,8 @@ function setStyle(style, key, value) {
1313 }
1414}
1515
16+ const CAPTURE_REGEX = / ( P o i n t e r C a p t u r e ) $ | C a p t u r e $ / i;
17+
1618// A logical clock to solve issues like https://github.com/preactjs/preact/issues/3927.
1719// When the DOM performs an event it leaves micro-ticks in between bubbling up which means that
1820// an event can trigger on a newly reated DOM-node while the event bubbles up.
@@ -64,8 +66,7 @@ export function setProperty(dom, name, value, oldValue, namespace) {
6466 }
6567 // Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6
6668 else if ( name [ 0 ] === 'o' && name [ 1 ] === 'n' ) {
67- useCapture =
68- name !== ( name = name . replace ( / ( P o i n t e r C a p t u r e ) $ | C a p t u r e $ / i, '$1' ) ) ;
69+ useCapture = name !== ( name = name . replace ( CAPTURE_REGEX , '$1' ) ) ;
6970
7071 // Infer correct casing for DOM built-in events:
7172 if (
@@ -98,7 +99,7 @@ export function setProperty(dom, name, value, oldValue, namespace) {
9899 ) ;
99100 }
100101 } else {
101- if ( namespace == 'http://www.w3.org/2000/svg' ) {
102+ if ( namespace == SVG_NAMESPACE ) {
102103 // Normalize incorrect prop usage for SVG:
103104 // - xlink:href / xlinkHref --> href (xlink:href was removed from SVG and isn't needed)
104105 // - className --> class
@@ -166,8 +167,7 @@ function createEventProxy(useCapture) {
166167 } else if ( e . _dispatched < eventHandler . _attached ) {
167168 return ;
168169 }
169- if ( options . event ) e = options . event ( e ) ;
170- return "handleEvent" in eventHandler ? eventHandler . handleEvent ( e ) : eventHandler ( e ) ;
170+ return eventHandler ( options . event ? options . event ( e ) : e ) ;
171171 }
172172 } ;
173173}
0 commit comments