How to use the @tarojs/shared.isArray function in @tarojs/shared

To help you get started, we’ve selected a few @tarojs/shared 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 NervJS / taro / packages / taro-runtime / src / dom / element.ts View on Github external
private _stopPropagation (event: TaroEvent) {
    // eslint-disable-next-line @typescript-eslint/no-this-alias
    let target = this
    // eslint-disable-next-line no-cond-assign
    while ((target = target.parentNode as this)) {
      const listeners = target.__handlers[event.type]

      if (!isArray(listeners)) {
        continue
      }

      for (let i = listeners.length; i--;) {
        const l = listeners[i]
        l._stop = true
      }
    }
  }
}
github NervJS / taro / packages / taro-runtime / src / dom / event_target.ts View on Github external
if (isOnce) {
      const wrapper = function () {
        handler.apply(this, arguments) // this 指向 Element
        this.removeEventListener(type, wrapper)
      }
      this.addEventListener(type, wrapper, {
        ...(options as AddEventListenerOptions),
        once: false
      })
      return
    }

    warn(isCapture, 'The event capture feature is unimplemented.')

    if (isArray(handlers)) {
      handlers.push(handler)
    } else {
      this.__handlers[type] = [handler]
    }
  }
github NervJS / taro / packages / taro-runtime / src / dom / event_target.ts View on Github external
public removeEventListener (type: string, handler: EventHandler) {
    type = type.toLowerCase()
    if (handler == null) {
      return
    }

    const handlers = this.__handlers[type]
    if (!isArray(handlers)) {
      return
    }

    const index = handlers.indexOf(handler)

    warn(index === -1, `事件: '${type}' 没有注册在 DOM 中,因此不会被移除。`)

    handlers.splice(index, 1)
  }
}
github NervJS / taro / packages / taro-mini-runner / src / template / index.ts View on Github external
function getValue (key: string) {
    if (Adapter.type === BUILD_TYPES.SWAN && isArray(swanSpecialAttrs[nodeName]) && swanSpecialAttrs[nodeName].includes(key)) {
      return `= ${attrs[key]} =`
    }

    return `{ ${attrs[key]} }`
  }
  return Object.keys(attrs)