Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro@4.0.7 转鸿蒙 cssStyleDeclaration 方法没有考虑到原型链上的属性取值 #16936

Open
jxxbd91 opened this issue Nov 27, 2024 · 1 comment

Comments

@jxxbd91
Copy link

jxxbd91 commented Nov 27, 2024

相关平台

鸿蒙

使用框架: Vue 3

复现步骤

  1. 实际使用的taro 版本 4.0.7,但是上面无法选中
  2. 源代码链接位置 https://github.com/NervJS/taro/blob/feat/4.0.8/packages/taro-platform-harmony/src/runtime-ets/dom/cssStyleDeclaration.ts#L76-L80
public getPropertyValue (prop: string): string | number {
    prop = prop.includes('-') ? toCamelCase(prop) : prop
    const node = this.el
    const value = node._st[prop]

    // 这里可能是从 this 的原型链上获取值,如果仅仅判断 this.el 是否有值在部分场景会报错。
    // 看看是否改成 return value === undefined ? this[prop] ?? '' : value
    return value === undefined ? '' : value
}

例如:在 vue3 runtime-dom 中会调用 style.setProperty 方法,由于经过了 Taro 的代理 https://github.com/NervJS/taro/blob/feat/4.0.8/packages/taro-platform-harmony/src/runtime-ets/dom/cssStyleDeclaration.ts#L106, 得到的返回结果是 空字符串,这个时候就会报错

vue3 代码链接: https://github.com/vuejs/core/blob/5a5406d002f568e928489920d0dcc7086c808a8d/packages/runtime-dom/src/modules/style.ts#L88

期望结果

可以正常调用不报错

实际结果

style.setProperty is not callable

环境信息

Taro CLI 4.0.7 environment info:
    System:
      OS: macOS 13.3.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
      Yarn: 1.22.11 - /usr/local/bin/yarn
      npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    npmPackages:
      @tarojs/cli: 4.0.7 => 4.0.7 
      @tarojs/components: 4.0.7 => 4.0.7 
      @tarojs/helper: 4.0.7 => 4.0.7 
      @tarojs/plugin-framework-vue3: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-alipay: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-h5: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-harmony-ets: ^4.0.7 => 4.0.7 
      @tarojs/plugin-platform-jd: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-qq: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-swan: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-tt: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-weapp: 4.0.7 => 4.0.7 
      @tarojs/runtime: 4.0.7 => 4.0.7 
      @tarojs/shared: 4.0.7 => 4.0.7 
      @tarojs/taro: 4.0.7 => 4.0.7 
      @tarojs/vite-runner: 4.0.7 => 4.0.8-beta.0 
      babel-preset-taro: 4.0.7 => 4.0.7 
      eslint-config-taro: 4.0.7 => 4.0.7 

image

This was referenced Nov 30, 2024
@jxxbd91
Copy link
Author

jxxbd91 commented Dec 2, 2024

#16972

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant