How to use the @tarojs/shared.Shortcuts.Style 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
}
  }

  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 / 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
          })
        }
      }
    }
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
      }