@semantic-ui/query
Advanced tools
Comparing version 0.0.36 to 0.0.37
@@ -26,5 +26,5 @@ { | ||
"dependencies": { | ||
"@semantic-ui/utils": "^0.0.36" | ||
"@semantic-ui/utils": "^0.0.37" | ||
}, | ||
"version": "0.0.36" | ||
"version": "0.0.37" | ||
} |
@@ -23,3 +23,2 @@ import { isClient } from '@semantic-ui/utils'; | ||
if(dollar) { | ||
@@ -39,3 +38,3 @@ originalDollar = window.$; | ||
} | ||
} | ||
}; | ||
@@ -42,0 +41,0 @@ // Add a restoreGlobals method to restore the original values of $ and $$ |
@@ -1,2 +0,2 @@ | ||
import { isPlainObject, clone, isString, isArray, isDOM, isFunction, findIndex, inArray, isClient, isObject, each } from '@semantic-ui/utils'; | ||
import { isPlainObject, isString, isArray, isDOM, isFunction, findIndex, inArray, isClient, isObject, each } from '@semantic-ui/utils'; | ||
@@ -8,3 +8,2 @@ /* | ||
export class Query { | ||
@@ -329,3 +328,3 @@ | ||
on(event, targetSelectorOrHandler, handlerOrOptions, options) { | ||
on(eventName, targetSelectorOrHandler, handlerOrOptions, options) { | ||
const eventHandlers = []; | ||
@@ -354,13 +353,18 @@ | ||
if (targetSelector) { | ||
delegateHandler = (e) => { | ||
delegateHandler = (event) => { | ||
let target; | ||
// if this event is composed from a web component | ||
// this is required to get the original path | ||
if (e.composed && e.composedPath) { | ||
const path = e.composedPath(); | ||
if (event.composed && event.composedPath) { | ||
// look through composed path bubbling into the attached element to see if any match target | ||
let path = event.composedPath(); | ||
const elIndex = findIndex(path, thisEl => thisEl == el); | ||
path = path.slice(0, elIndex); | ||
target = path.find(el => el instanceof Element && el.matches && el.matches(targetSelector)); | ||
} | ||
else { | ||
// keep things simple for most basic uses | ||
target = e.target.closest(targetSelector); | ||
target = event.target.closest(targetSelector); | ||
} | ||
@@ -370,3 +374,3 @@ | ||
// If a matching target is found, call the handler with the correct context | ||
handler.call(target, e); | ||
handler.call(target, event); | ||
} | ||
@@ -380,3 +384,3 @@ }; | ||
if (domEL.addEventListener) { | ||
domEL.addEventListener(event, eventListener, { signal, ...eventSettings }); | ||
domEL.addEventListener(eventName, eventListener, { signal, ...eventSettings }); | ||
} | ||
@@ -386,3 +390,3 @@ | ||
el, | ||
event, | ||
eventName, | ||
eventListener, | ||
@@ -408,3 +412,3 @@ abortController, | ||
one(event, targetSelectorOrHandler, handlerOrOptions, options) { | ||
one(eventName, targetSelectorOrHandler, handlerOrOptions, options) { | ||
let handler; | ||
@@ -426,14 +430,14 @@ let targetSelector; | ||
// Unbind the event handler after it has been invoked once | ||
this.off(event, wrappedHandler); | ||
this.off(eventName, wrappedHandler); | ||
}; | ||
return (targetSelector) | ||
? this.on(event, targetSelector, wrappedHandler, options) | ||
: this.on(event, wrappedHandler, options) | ||
? this.on(eventName, targetSelector, wrappedHandler, options) | ||
: this.on(eventName, wrappedHandler, options) | ||
; | ||
} | ||
off(event, handler) { | ||
off(eventName, handler) { | ||
Query.eventHandlers = Query.eventHandlers.filter((eventHandler) => { | ||
if ( | ||
eventHandler.event === event && | ||
eventHandler.eventName === eventName && | ||
(!handler || | ||
@@ -447,3 +451,3 @@ handler?.eventListener == eventHandler.eventListener || | ||
if(el.removeEventListener) { | ||
el.removeEventListener(event, eventHandler.eventListener); | ||
el.removeEventListener(eventName, eventHandler.eventListener); | ||
} | ||
@@ -457,3 +461,3 @@ return false; | ||
trigger(eventType, eventParams) { | ||
trigger(eventName, eventParams) { | ||
return this.each(el => { | ||
@@ -463,3 +467,3 @@ if (typeof el.dispatchEvent !== 'function') { | ||
} | ||
const event = new Event(eventType, { bubbles: true, cancelable: true }); | ||
const event = new Event(eventName, { bubbles: true, cancelable: true }); | ||
if(eventParams) { | ||
@@ -466,0 +470,0 @@ Object.assign(event, eventParams); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93140
2318
+ Added@semantic-ui/utils@0.0.37(transitive)
- Removed@semantic-ui/utils@0.0.36(transitive)
Updated@semantic-ui/utils@^0.0.37