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

变量作用域设计 #1

Closed
army8735 opened this issue Sep 19, 2014 · 2 comments
Closed

变量作用域设计 #1

army8735 opened this issue Sep 19, 2014 · 2 comments
Labels
Milestone

Comments

@army8735
Copy link
Owner

传统的预编译器无外乎都按照@import后的先后顺序,主要原因在于这些家伙将@import的文件按顺序导入合并为一个文件,这和css顺序规范一致,但缺陷有二:

  • 没将子文件拆分。
  • 造成很不好的习惯头部@import作为变量专门存放
  • 相互之间变量冲突

无拆分目前通过变通方法做到文件关系对应;
第二个则十分不妥,文件拆分的本意是模块化区分,文件之间相互解耦独立,目前做法既不符合模块化的概念又耦合,如果是写commonjs时我将所有变量作为一个模块申明然后放在头部首先导入,让其它模块引用不知作何感想。

之前more的设计是层级式变量,即变量申明后作用域为本文件以及子文件,而父文件无访问权限。避免冲突。
同时,增加配置项,想要全局方位可以config。这样一个项目的全局变量、所有项目的全局变量全可以一次性配置。

如今config增强了,可以用传入一个css文件作为config。层级式变量是否要保留或是其它还没想好。又或是有更好的设计?

@army8735 army8735 added this to the 0.7.0 milestone Sep 19, 2014
@army8735
Copy link
Owner Author

https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables
mozilla草案,和@import一样顺序优先

@army8735
Copy link
Owner Author

暂时放弃拆分文件后保持页面作用域,单css引用可以通过ref判断从属关系,但也增加使用复杂度。
难点在于页面中引入多个css时很难将这几个css关联起来共享作用域。
提供拆分的同时parseFile第2个参数变成combo,使用传统合并方式解析。

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

No branches or pull requests

1 participant