How to use the @tarojs/shared.Shortcuts.Class 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 / render.ts View on Github external
if (isText(node)) {
    return {
      [Shortcuts.Text]: node.nodeValue,
      [Shortcuts.NodeName]: node.nodeName
    }
  }

  const data: MiniData = {
    ...node.props,
    [Shortcuts.Childnodes]: node.childNodes.map(hydrate),
    [Shortcuts.NodeName]: node.nodeName,
    uid: node.uid
  }

  if (node.className) {
    data[Shortcuts.Class] = node.className
  }

  if (node.cssText) {
    data[Shortcuts.Style] = node.cssText
  }

  // eslint-disable-next-line dot-notation
  delete data['class']
  // eslint-disable-next-line dot-notation
  delete data['style']

  return data
}
github NervJS / taro / packages / taro-runtime / src / dom / element.ts View on Github external
public setAttribute (qualifiedName: string, value: string | boolean): void {
    if (qualifiedName === 'style') {
      this.style.cssText = value as string
      qualifiedName = Shortcuts.Style
    } else if (qualifiedName === 'id') {
      eventSource.delete(this.uid)
      this.uid = value as string
      eventSource.set(value as string, this)
      qualifiedName = 'uid'
    } else {
      this.props[qualifiedName] = value as string
      if (qualifiedName === 'class') {
        qualifiedName = Shortcuts.Class
      }
      if (qualifiedName.startsWith('data-')) {
        if (this.dataset === EMPTY_OBJ) {
          this.dataset = Object.create(null)
        }
        this.dataset[qualifiedName.replace(/^data-/, '')] = value
      }
    }

    this.enqueueUpdate({
      path: `${this._path}.${qualifiedName}`,
      value
    })
  }