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

Toutiao has a bug of support rpx with !important #160

Closed
1 of 6 tasks
malash opened this issue Apr 13, 2022 · 1 comment · Fixed by #161
Closed
1 of 6 tasks

Toutiao has a bug of support rpx with !important #160

malash opened this issue Apr 13, 2022 · 1 comment · Fixed by #161

Comments

@malash
Copy link
Collaborator

malash commented Apr 13, 2022

Description

For example height: 200rpx !important; is a line of valid CSS code and it works in Toutiao. But after uglify it becomes height:200rpx!important; and it won't work.

Not all !important statements fail. To reproduce the bug there are several requirements:

  1. Must use rpx. height:200px!important; is ok and also color:red!important is ok.
  2. There shoule be no space before the !important.

Reproduct link

https://developer.toutiao.com/ide/minicode/vpNKxu

Reproduct steps

  1. Open the link
  2. Inspect the elements

95850880-75dc-11ea-89d8-978179aa6d55

Impact

Some CSS failed on Toutiao.

Temporary solution

We can write a Webpack loader to revert the uglify.

module.exports = function main(this: loader.LoaderContext, source: string | Buffer) {
  if (this.cacheable) {
    this.cacheable();
  }

  return source.toString().replace(/!important/g, ' !important');
};

Platforms

  • WeChat
  • Baidu ( including Xiaohongshu )
  • QQ
  • Alipay
  • Toutiao
  • KuaiApp
@malash
Copy link
Collaborator Author

malash commented Apr 13, 2022

@malash malash linked a pull request Apr 13, 2022 that will close this issue
malash added a commit that referenced this issue Jul 21, 2023
malash added a commit that referenced this issue Jul 23, 2023
malash added a commit that referenced this issue Jul 23, 2023
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

Successfully merging a pull request may close this issue.

1 participant