Skip to content

Commit

Permalink
added support for seding the original event to the "trigger" events m…
Browse files Browse the repository at this point in the history
…ethod
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Jul 30, 2022
1 parent d33fd22 commit cd70179
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/parts/EventDispatcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { extend } from './helpers'

// clones an event since it cannot be destructured
function cloneEvent(e) {
if (!e) return;
let clone = new Function();
for (let p in e) {
let d = Object.getOwnPropertyDescriptor(e, p);
if (d && (d.get || d.set)) Object.defineProperty(clone, p, d); else clone[p] = e[p];
}
Object.setPrototypeOf(clone, e);
return clone;
}

export default function EventDispatcher( instance ){
// Create a DOM EventTarget object
var target = document.createTextNode('')
Expand Down Expand Up @@ -44,6 +56,9 @@ export default function EventDispatcher( instance ){
eventData = opts.cloneData ? extend({}, eventData) : eventData
eventData.tagify = this

if( data.event )
eventData.event = cloneEvent(data.event)

// TODO: move the below to the "extend" function
if( data instanceof Object )
for( var prop in data )
Expand Down

0 comments on commit cd70179

Please sign in to comment.