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

plugin-html转译后css优先级有误 #10660

Open
broven opened this issue Nov 15, 2021 · 1 comment
Open

plugin-html转译后css优先级有误 #10660

broven opened this issue Nov 15, 2021 · 1 comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@broven
Copy link

broven commented Nov 15, 2021

相关平台

微信小程序

小程序基础库: 2.11.0
使用框架: React

复现步骤

  • 为什么本来到样式转换到小程序优先级就坏了
    • 转换前
      • 之前组件库有一些重制样式

        ``` css
        div{
          padding: 0px;
        }
        /* 针对div 对class*/
        .biz{
          padding: 2px;
        }
        ```
        
        • 此时根据 CSS优先级计算,biz是无论如何都会比重制样式高的
      • 转换后

        ``` CSS
        .h5-div{
          padding: 0px;
        }
        /* 针对div 对class*/
        .biz{
          padding: 2px;
        }
        ```
        

此时 div 的优先级就和class选择器同级了

期望结果

转译后的优先级和转译前相同

实际结果

之前的标签样式会与类样式同优先级

环境信息

👽 Taro v3.3.12


  Taro CLI 3.3.12 environment info:
    System:
      OS: macOS 12.0.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 16.10.0 - /var/folders/9x/z9ks542s7y99fmscy1myc3vh0000gp/T/yarn--1636958988741-0.6400798677934707/node
      Yarn: 1.22.15 - /var/folders/9x/z9ks542s7y99fmscy1myc3vh0000gp/T/yarn--1636958988741-0.6400798677934707/yarn
      npm: 7.24.0 - /var/folders/9x/z9ks542s7y99fmscy1myc3vh0000gp/T/fnm_multishells/28938_1636688252634/bin/npm
    npmPackages:
      @tarojs/cli: ^3.2.0 => 3.3.12
      @tarojs/components: ^3.2.0 => 3.3.12
      @tarojs/mini-runner: ^3.2.0 => 3.3.12
      @tarojs/react: ^3.2.0 => 3.3.12
      @tarojs/runtime: ^3.2.0 => 3.3.12
      @tarojs/taro: ^3.2.0 => 3.3.12
      @tarojs/webpack-runner: ^3.2.0 => 3.3.12
      babel-preset-taro: ^3.2.0 => 3.3.12
      eslint-config-taro: ^3.2.0 => 3.3.12
      react: ^16.14.0 => 16.14.0
      taro-ui: ^3.0.0-alpha => 3.0.0-alpha.10

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Nov 15, 2021
@broven
Copy link
Author

broven commented Nov 15, 2021

想到的方案
提高原class选择器优先级,加入一个class类名 让原class类优先级提高一层

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

No branches or pull requests

1 participant