How to use the @tarojs/shared.warn 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 / event_target.ts View on Github external
isOnce = Boolean(options.once)
    }

    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-runtime / src / dom / style.ts View on Github external
set (this: Style, newVal: string) {
        const old = this[styleKey]
        if (newVal) {
          this._usedStyleProp.add(styleKey)
        }

        warn(
          styleKey === 'style' && newVal.startsWith('data:image/'),
          '直接在图片地址使用 data64 会造成渲染性能急剧下降,考虑在 CSS 类使用 base64 或其它替代方案。'
        )

        if (old !== newVal) {
          this._value[styleKey] = newVal
          this._element.enqueueUpdate({
            path: `${this._element._path}.${Shortcuts.Style}`,
            value: this.cssText
          })
        }
      }
    }