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

PReact 代码压缩后,video 标签的 controls 属性设置 false 不生效 #12589

Closed
wenshin opened this issue Sep 28, 2022 · 3 comments · Fixed by #12608
Closed

PReact 代码压缩后,video 标签的 controls 属性设置 false 不生效 #12589

wenshin opened this issue Sep 28, 2022 · 3 comments · Fixed by #12608
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@wenshin
Copy link
Contributor

wenshin commented Sep 28, 2022

相关平台

微信小程序

复现仓库

https://github.com/wenshin/taro-issue-demo
小程序基础库: 2.26.1
使用框架: React

复现步骤

  1. 使用 PReact 代替 React
  2. 页面添加 Video 标签,并设置 controls={false}
  3. config/dev.js 中把 preact 等公共依赖提前压缩,避免预览开发版时体积过大
  4. 通过 dev:weapp 运行,

期望结果

在 devtools 和真机都不能看到原生控制器

实际结果

在 devtools 和真机都能看到原生控制器

环境信息

Taro CLI 3.4.9 environment info:
    System:
      OS: macOS 11.6.5
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
      Yarn: 1.22.17 - ~/.nvm/versions/node/v14.18.1/bin/yarn
      npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
    npmPackages:
      @tarojs/components: 3.4.14 => 3.4.14
      @tarojs/mini-runner: 3.4.9 => 3.4.9
      @tarojs/plugin-framework-react: 3.4.14 => 3.4.14
      @tarojs/runtime: 3.4.14 => 3.4.14
      @tarojs/taro: 3.4.14 => 3.4.14
      @tarojs/webpack-runner: 3.4.9 => 3.4.9
      babel-preset-taro: 3.4.9 => 3.4.9
      eslint-config-taro: 3.4.9 => 3.4.9
      taro-ui: 3.0.0-alpha.10 => 3.0.0-alpha.10
    npmGlobalPackages:
      typescript: 4.7.2
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Sep 28, 2022
@wenshin
Copy link
Contributor Author

wenshin commented Sep 28, 2022

经调试发现,该 commit 6065b1c 修复时未兼容代码压缩后的问题。导致 node._dom 获取到 undefined。

Pasted Graphic

建议方案

把下面代码

const dom = newVNode._dom

改为

const domProp = Object.keys(newVNode).find(k => (newVNode[k] && newVNode[k].setAttribute));
const dom = newVNode[domProp];

@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 28, 2022

@wenshin 感谢反馈并定位,可以直接提一下 PR 哈~

另外改为 const domProp = Object.keys(newVNode).find(k => (newVNode[k]?.setAttribute)) 这样更简洁些~

@wenshin
Copy link
Contributor Author

wenshin commented Oct 3, 2022

已经提 PR

@Chen-jj Chen-jj linked a pull request Oct 9, 2022 that will close this issue
17 tasks
@Chen-jj Chen-jj added this to the 3.5.7 milestone Oct 16, 2022
Chen-jj added a commit that referenced this issue Oct 16, 2022
* fix(preact): 修复 PReact 压缩后属性设置不生效问题 (#12589)

* fix: ci

* fix: ci

Co-authored-by: yanwenxu17158 <yanwenxu17158@ipalfish.com>
Co-authored-by: chenjiajian <798095202@qq.com>
KkZsc pushed a commit to KkZsc/taro that referenced this issue Dec 5, 2022
* fix(preact): 修复 PReact 压缩后属性设置不生效问题 (NervJS#12589)

* fix: ci

* fix: ci

Co-authored-by: yanwenxu17158 <yanwenxu17158@ipalfish.com>
Co-authored-by: chenjiajian <798095202@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants