From 75fca7931365e0b394aed2e2f3577391dc558a18 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 20 Aug 2015 13:43:57 +0800 Subject: [PATCH] remove magic code, use getBoundingClientRect replace offsetWidth --- components/tag/index.jsx | 20 +++++++++++--------- nico.js | 3 +-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/tag/index.jsx b/components/tag/index.jsx index b4f21cafd3..c037f637a5 100644 --- a/components/tag/index.jsx +++ b/components/tag/index.jsx @@ -14,10 +14,6 @@ class AntTag extends React.Component { close(e) { let dom = React.findDOMNode(this); - dom.style.width = dom.offsetWidth + 'px'; - // Magic code - // 重复是去除浏览器渲染bug; - dom.style.width = dom.offsetWidth + 'px'; this.setState({ closing: true }); @@ -30,6 +26,11 @@ class AntTag extends React.Component { this.props.onClose.call(this, e); } + componentDidMount() { + let dom = React.findDOMNode(this); + dom.style.width = (dom.getBoundingClientRect().width || dom.offsetWidth) + 'px'; + } + render() { let close = this.props.closable ? : ''; @@ -38,17 +39,18 @@ class AntTag extends React.Component { let className = this.props.prefixCls + ' ' + colorClass; className = this.state.closing ? className + ' ' + this.props.prefixCls + '-close' : className; - return (this.state.closed && !this.state.closing) ? null :
- - {close} -
; + return (this.state.closed && !this.state.closing) ? null + :
+ + {close} +
; } } AntTag.defaultProps = { prefixCls: prefixCls, closable: false, - onClose: function () {} + onClose: function() {} }; export default AntTag; diff --git a/nico.js b/nico.js index c785105686..10845fe98d 100644 --- a/nico.js +++ b/nico.js @@ -90,8 +90,7 @@ exports.middlewares = [ watchOptions: { aggregateTimeout: 300, poll: true - }, - quiet: true + } }); try { return handler(req, res, next); -- GitLab