Skip to content

Commit ed1304f

Browse files
committed
safari 12.3 fix
1 parent f7ccb90 commit ed1304f

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

src/diff/props.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,24 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
124124
* @private
125125
*/
126126
function eventProxy(e) {
127-
const eventHandler = this._listeners[e.type + false];
128-
/**
129-
* This trick is inspired by Vue https://github.com/vuejs/core/blob/main/packages/runtime-dom/src/modules/events.ts#L90-L101
130-
* when the dom performs an event it leaves micro-ticks in between bubbling up which means that an event can trigger on a newly
131-
* created DOM-node while the event bubbles up, this can cause quirky behavior as seen in https://github.com/preactjs/preact/issues/3927
132-
*/
133-
if (!e._dispatched) {
134-
// When an event has no _dispatched we know this is the first event-target in the chain
135-
// so we set the initial dispatched time.
136-
e._dispatched = Date.now();
137-
// When the _dispatched is smaller than the time when the targetted event handler was attached
138-
// we know we have bubbled up to an element that was added during patching the dom.
139-
} else if (e._dispatched <= eventHandler._attached) {
140-
return;
127+
if (this._listeners) {
128+
const eventHandler = this._listeners[e.type + false];
129+
/**
130+
* This trick is inspired by Vue https://github.com/vuejs/core/blob/main/packages/runtime-dom/src/modules/events.ts#L90-L101
131+
* when the dom performs an event it leaves micro-ticks in between bubbling up which means that an event can trigger on a newly
132+
* created DOM-node while the event bubbles up, this can cause quirky behavior as seen in https://github.com/preactjs/preact/issues/3927
133+
*/
134+
if (!e._dispatched) {
135+
// When an event has no _dispatched we know this is the first event-target in the chain
136+
// so we set the initial dispatched time.
137+
e._dispatched = Date.now();
138+
// When the _dispatched is smaller than the time when the targetted event handler was attached
139+
// we know we have bubbled up to an element that was added during patching the dom.
140+
} else if (e._dispatched <= eventHandler._attached) {
141+
return;
142+
}
143+
return eventHandler(options.event ? options.event(e) : e);
141144
}
142-
return eventHandler(options.event ? options.event(e) : e);
143145
}
144146

145147
/**
@@ -148,5 +150,7 @@ function eventProxy(e) {
148150
* @private
149151
*/
150152
function eventProxyCapture(e) {
151-
return this._listeners[e.type + true](options.event ? options.event(e) : e);
153+
if (this._listeners) {
154+
return this._listeners[e.type + true](options.event ? options.event(e) : e);
155+
}
152156
}

0 commit comments

Comments
 (0)