@domql/event
Advanced tools
Comparing version 2.5.168 to 2.5.169
@@ -30,2 +30,8 @@ "use strict"; | ||
var import_utils = require("@domql/utils"); | ||
const getOnOrPropsEvent = (param, element) => { | ||
var _a, _b; | ||
const onEvent = (_a = element.on) == null ? void 0 : _a[param]; | ||
const onPropEvent = (_b = element.props) == null ? void 0 : _b["on" + param.slice(0, 1).toUpperCase() + param.slice(1)]; | ||
return onEvent || onPropEvent; | ||
}; | ||
const applyEvent = (param, element, state, context, options) => { | ||
@@ -35,6 +41,6 @@ return param.call(element, element, state || element.state, context || element.context, options); | ||
const triggerEventOn = (param, element, options) => { | ||
var _a; | ||
if (element.on && (0, import_utils.isFunction)(element.on[param])) { | ||
const appliedFunction = getOnOrPropsEvent(param, element); | ||
if (appliedFunction) { | ||
const { state, context } = element; | ||
return applyEvent(element.on[param] || ((_a = element.props) == null ? void 0 : _a[param]), element, state, context, options); | ||
return applyEvent(appliedFunction, element, state, context, options); | ||
} | ||
@@ -46,6 +52,6 @@ }; | ||
const triggerEventOnUpdate = (param, updatedObj, element, options) => { | ||
var _a; | ||
if (element.on && (0, import_utils.isFunction)(element.on[param])) { | ||
const appliedFunction = getOnOrPropsEvent(param, element); | ||
if (appliedFunction) { | ||
const { state, context } = element; | ||
return applyEventUpdate(element.on[param] || ((_a = element.props) == null ? void 0 : _a[param]), updatedObj, element, state, context, options); | ||
return applyEventUpdate(appliedFunction, updatedObj, element, state, context, options); | ||
} | ||
@@ -63,3 +69,2 @@ }; | ||
const applyEventsOnNode = (element, options) => { | ||
var _a; | ||
const { node, on } = element; | ||
@@ -69,3 +74,3 @@ for (const param in on) { | ||
continue; | ||
const appliedFunction = element.on[param] || ((_a = element.props) == null ? void 0 : _a[param]); | ||
const appliedFunction = getOnOrPropsEvent(param, element); | ||
if ((0, import_utils.isFunction)(appliedFunction)) { | ||
@@ -72,0 +77,0 @@ node.addEventListener(param, (event) => { |
18
on.js
@@ -5,2 +5,8 @@ 'use strict' | ||
const getOnOrPropsEvent = (param, element) => { | ||
const onEvent = element.on?.[param] | ||
const onPropEvent = element.props?.['on' + param.slice(0, 1).toUpperCase() + param.slice(1)] | ||
return onEvent || onPropEvent | ||
} | ||
export const applyEvent = (param, element, state, context, options) => { | ||
@@ -11,5 +17,6 @@ return param.call(element, element, state || element.state, context || element.context, options) | ||
export const triggerEventOn = (param, element, options) => { | ||
if (element.on && isFunction(element.on[param])) { | ||
const appliedFunction = getOnOrPropsEvent(param, element) | ||
if (appliedFunction) { | ||
const { state, context } = element | ||
return applyEvent(element.on[param] || element.props?.[param], element, state, context, options) | ||
return applyEvent(appliedFunction, element, state, context, options) | ||
} | ||
@@ -23,5 +30,6 @@ } | ||
export const triggerEventOnUpdate = (param, updatedObj, element, options) => { | ||
if (element.on && isFunction(element.on[param])) { | ||
const appliedFunction = getOnOrPropsEvent(param, element) | ||
if (appliedFunction) { | ||
const { state, context } = element | ||
return applyEventUpdate(element.on[param] || element.props?.[param], updatedObj, element, state, context, options) | ||
return applyEventUpdate(appliedFunction, updatedObj, element, state, context, options) | ||
} | ||
@@ -60,3 +68,3 @@ } | ||
const appliedFunction = element.on[param] || element.props?.[param] | ||
const appliedFunction = getOnOrPropsEvent(param, element) | ||
if (isFunction(appliedFunction)) { | ||
@@ -63,0 +71,0 @@ node.addEventListener(param, event => { |
{ | ||
"name": "@domql/event", | ||
"version": "2.5.168", | ||
"version": "2.5.169", | ||
"license": "MIT", | ||
@@ -31,5 +31,5 @@ "type": "module", | ||
"@domql/report": "^2.5.162", | ||
"@domql/utils": "^2.5.168" | ||
"@domql/utils": "^2.5.169" | ||
}, | ||
"gitHead": "6c935c3d1ff70096bb532e9c5426ffc5af0677dc" | ||
"gitHead": "ae523f95551eac614ee00baf3c425cb6c4271a2c" | ||
} |
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
15046
337
Updated@domql/utils@^2.5.169