Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getData = (key, el) => {
if (isElement(key) && typeof el === 'undefined') {
el = key
key = undefined
}
const cache = getCachedData(el)
if (key) {
if (!(key in cache)) {
let value = el.dataset[key] || el.dataset[camelize(key, false)]
if (value !== undefined) {
try {
value = JSON.parse(value)
} catch (e) {} // eslint-disable-line
cache[key] = value
}
}
return cache[key]
}
return cache
}
export const setStyle = (key, value, el) => {
if (isString(key) && isElement(el)) {
if (value || value === 0) {
if (isCSSVariable(key)) {
el.style.setProperty(key, value)
} else {
key = camelize(key, false)
if (isNumeric(value) && isCssNumber(key)) {
value += 'px'
}
el.style[key] = value
}
} else {
el.style.removeProperty(dasherize(key))
}
} else if (isObject(key)) {
if (isElement(value) && typeof el === 'undefined') {
el = value
value = undefined
}
let prop
for (prop in key) {
plugin.prototype.trigger = function(eventType, ...params) {
if (eventType instanceof Event) {
trigger(eventType, this.element)
eventType = eventType.type
} else {
trigger(this.selfEventName(eventType), this, ...params, this.element)
}
eventType = camelize(eventType)
const onFunction = `on${eventType}`
if (
!isUndefined(this.options) &&
!isUndefined(this.options[onFunction]) &&
isFunction(this.options[onFunction])
) {
this.options[onFunction].apply(this, params)
}
}