How to use the @pluginjs/utils.camelize function in @pluginjs/utils

To help you get started, we’ve selected a few @pluginjs/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pluginjs / pluginjs / modules / dom / src / main.js View on Github external
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
}
github pluginjs / pluginjs / modules / styled / src / main.js View on Github external
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) {
github pluginjs / pluginjs / modules / decorator / src / eventable.js View on Github external
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)
      }
    }