Skip to content

Commit

Permalink
safari 12.3 fix (#4253)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock authored Jan 16, 2024
1 parent f7ccb90 commit b3480e8
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,24 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
* @private
*/
function eventProxy(e) {
const eventHandler = this._listeners[e.type + false];
/**
* This trick is inspired by Vue https://github.com/vuejs/core/blob/main/packages/runtime-dom/src/modules/events.ts#L90-L101
* when the dom performs an event it leaves micro-ticks in between bubbling up which means that an event can trigger on a newly
* created DOM-node while the event bubbles up, this can cause quirky behavior as seen in https://github.com/preactjs/preact/issues/3927
*/
if (!e._dispatched) {
// When an event has no _dispatched we know this is the first event-target in the chain
// so we set the initial dispatched time.
e._dispatched = Date.now();
// When the _dispatched is smaller than the time when the targetted event handler was attached
// we know we have bubbled up to an element that was added during patching the dom.
} else if (e._dispatched <= eventHandler._attached) {
return;
if (this._listeners) {
const eventHandler = this._listeners[e.type + false];
/**
* This trick is inspired by Vue https://github.com/vuejs/core/blob/main/packages/runtime-dom/src/modules/events.ts#L90-L101
* when the dom performs an event it leaves micro-ticks in between bubbling up which means that an event can trigger on a newly
* created DOM-node while the event bubbles up, this can cause quirky behavior as seen in https://github.com/preactjs/preact/issues/3927
*/
if (!e._dispatched) {
// When an event has no _dispatched we know this is the first event-target in the chain
// so we set the initial dispatched time.
e._dispatched = Date.now();
// When the _dispatched is smaller than the time when the targetted event handler was attached
// we know we have bubbled up to an element that was added during patching the dom.
} else if (e._dispatched <= eventHandler._attached) {
return;
}
return eventHandler(options.event ? options.event(e) : e);
}
return eventHandler(options.event ? options.event(e) : e);
}

/**
Expand All @@ -148,5 +150,7 @@ function eventProxy(e) {
* @private
*/
function eventProxyCapture(e) {
return this._listeners[e.type + true](options.event ? options.event(e) : e);
if (this._listeners) {
return this._listeners[e.type + true](options.event ? options.event(e) : e);
}
}

0 comments on commit b3480e8

Please sign in to comment.