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

[BUG]用 rax-scripts lineCSS 的方式打包 animate.css,在ios 上开启动画减弱的设备上会报错 #427

Closed
maisui99 opened this issue Sep 7, 2020 · 0 comments · Fixed by #433
Assignees

Comments

@maisui99
Copy link

maisui99 commented Sep 7, 2020

出问题的代码:https://github.com/raxjs/rax-scripts/blob/083d98416234e1d031c6e405d01e1fc42ac8eb6f/packages/stylesheet-loader/src/index.js#L156

inlinceCSS 的模式打包 animate.css,_styles[key] 可能为空,导致 Object.assign 报错。

打包前:

@media print, (prefers-reduced-motion: reduce) {
  .animate__animated {
    -webkit-animation-duration: 1ms !important;
    animation-duration: 1ms !important;
    -webkit-transition-duration: 1ms !important;
    transition-duration: 1ms !important;
    -webkit-animation-iteration-count: 1 !important;
    animation-iteration-count: 1 !important;
  }

  .animate__animated[class*='Out'] {
    opacity: 0;
  }
}

打包后

var i = {
        animate__animated: {
          WebkitAnimationDuration: "1ms !important",
          animationDuration: "1ms !important",
          WebkitTransitionDuration: "1ms !important",
          transitionDuration: "1ms",
          WebkitAnimationIterationCount: "1 !important",
          animationIterationCount: "1 !important"
        }, 
        "animate__animated[class*='Out']": { opacity: 0 } // 这一条在 _styles 里不存在
};

要看下为啥这条样式在打包后丢失了。

以及为了保证健壮性,建议可以加上 为空判断 || {},来兼容不报错:

_styles[key] = Object.assign(_styles[key] || {}, ruleData[key]);
@maisui99 maisui99 changed the title [BUG]用 rax-scripts lineCSS 的方式打包 animate.css,在部分 ios 13.x 设备上会报错 [BUG]用 rax-scripts lineCSS 的方式打包 animate.css,在部分 ios 13.6.1 设备上会报错 Sep 7, 2020
@maisui99 maisui99 changed the title [BUG]用 rax-scripts lineCSS 的方式打包 animate.css,在部分 ios 13.6.1 设备上会报错 [BUG]用 rax-scripts lineCSS 的方式打包 animate.css,在ios 上开启动画减弱的设备上会报错 Sep 9, 2020
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.

2 participants