Comments (9)
addClass中关于多个class以空格分割的问题,我觉得是为性能考虑吧,毕竟多次调用 addClass 看起来也不爽,折衷一下,可以实现为 addClass(class1, class2, ...),这样也清晰了
from esui.
addClass
和removeClass
接受多个class是可以理解的,问题就是应用的场景有多少(从控件的抽象体系来看)
但是hasClass
多个class似乎并不是一个很好的设计,其接口的理解性很低,多个class之间是OR还是AND的关系?
from esui.
题外话:如果现在lib中的东西是原封不动从tangram弄过来的话,这大概是我第一次认真地看tangram的源码,只想吐槽这代码质量是有多差……
历史问题,这些代码都是好几年前的了,可以理解的。
有些实现尽可能采用浏览器的实现,比如addClass,hasClass,bind之类的?
from esui.
我觉得尽量简单点,我们是为ui库做lib抽象,不是为业务开发做lib。尽量采用浏览器实现我觉得也是OK的(如classList)
from esui.
还有我稍微解释下,正则用new RegExp(\x24)不用/...$/原因是ctpl发现$就会去做变量替换,所以tangram中基本所有正则都是new
from esui.
@errorrik 所以我可以修改一下这里的实现,用正则直接量是吧?
@leeight @errorrik 关于使用浏览器原生实现,我思考这个问题没有1年也有个9月了,我的疑惑是,既然还是需要兼容性的实现代码,那么增加一个if分支,额外增加脚本体积,换过来的是什么,一些的性能提升能够成为解决瓶颈的关键吗?(当然显得很牛逼这种理由就不需要了)
from esui.
补充一下,bind
这个函数我会倾向于尽量用原生的实现,是因为原生的bind
其实是通过[[TargetFunction]]
搞的,一个好处是,单步调试的时候,一次step in就可以跳到原函数去,而不原生实现至少要过一个闭包,step in 按到手酸。而一般调试都是在支持bind
的浏览器下玩的……
from esui.
@otakustay
嗯,是的,可以用正则直接量。我自己也很烦new RegExp,性能又差又难看
from esui.
在 d3354b8 做了下代码的清理:
- 正则用直接量
format
只支持${name}
形式的hasClass
、addClass
、removeClass
只支持一个className- 添加
toggleClass
inherits
去掉__type
和extends
这几个东西的逻辑bind
接口与Function.prototype.bind
一致- 保留
page
和date
二级命名空间
from esui.
Related Issues (20)
- 日程投放控件 HOT 4
- InputCollection 应当继承 ControlCollection HOT 1
- Table 的 overflowX 属性为非 hidden 的时候多出一个横向滚动条 HOT 3
- BoxGroup有一处事件没使用addDOMEvent绑定
- 解决set和setProperties触发change的问题
- Table的依赖不全
- 控件初始化子控件时的valueReplacer管理
- 控件初始化子控件时的valueReplacer管理
- 控件初始化子控件时的valueReplacer管理
- 指定元素的销毁子控件
- Select 控件对于value比较判断的兼容性问题 HOT 2
- 希望能添加一些布局相关的组件 HOT 4
- 对于带有数据源的控件是否应该支持外部不提供数据源的场景的表决 HOT 19
- addChild的时候添加校验 HOT 6
- viewContext的疑问 HOT 3
- 加个Lisence HOT 1
- MonthView的年月下拉框格式可调 HOT 1
- 渐变背景的问题
- Panel控件的addContent方法不适用table布局 HOT 2
- 关于拓展组件
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esui.