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

Input props remove assign #14

Merged
merged 2 commits into from
May 19, 2016
Merged

Input props remove assign #14

merged 2 commits into from
May 19, 2016

Conversation

shepherdwind
Copy link

问题

{...props} 等效于 assign({}, props)

assign 方法在 node 和 浏览器上表现不一致,chrome 最新版本 assign 之后,安装 key 的字母顺序。这会导致浏览器和服务器渲染不一致:

image

浏览器上相当于

<input type="checkebox" className="foo"/>

服务端

<input className="foo" type="checkebox" />

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 84.746% when pulling e7d4cdd on input-props-sort into 31a3566 on master.

@xujihui1985
Copy link

这种透传的方式是很蛋疼,最好全都是固定下来的

@shepherdwind
Copy link
Author

感觉这里 type 直接写死应该也没问题,checkbox 难道 type 还会是其他?style 感觉更加不需要传递了,但不知道会不会有兼容问题,就也写上了。 @yiminghe 看看?

@@ -84,7 +84,8 @@ export default class Checkbox extends React.Component {
>
<span className={`${prefixCls}-inner`} />
<input
{...props}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不这样传,如果用户用了 disabled 之类,要一个一个加上去么。。

@yiminghe
Copy link
Member

disabled 处理下, style 处理倒是错误的, style 是在顶层的

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 84.746% when pulling e7c60bb on input-props-sort into 31a3566 on master.

@yiminghe yiminghe merged commit 18b0d66 into master May 19, 2016
@yiminghe yiminghe deleted the input-props-sort branch May 19, 2016 07:41
@afc163
Copy link
Member

afc163 commented Jun 7, 2016

facebook/react#4616

@afc163
Copy link
Member

afc163 commented Jun 7, 2016

facebook/react#6451

@afc163
Copy link
Member

afc163 commented Jun 7, 2016

我感觉都写死很不好,看上面的 issues 这算是老 v8 的 bug。sindresorhus/object-assign#32 针对这些问题搞了一个解决方案。

@shepherdwind 看看是否可以在服务端用 [email protected] 来解决?

应该不行,需要 babel 解决,再持续关注吧。

@yiminghe
Copy link
Member

yiminghe commented Jun 7, 2016

这个固定写死也没多少,否则以后 typescript 类型没法写

@paranoidjk
Copy link
Member

facebook/react#6451 (comment)

react 官方引入了 object-assign ....

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 this pull request may close these issues.

7 participants