Skip to content

Commit fdb87ee

Browse files
author
Paul Sachs
committed
truncate child hides when nothing is truncated.
1 parent e46cc7b commit fdb87ee

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

lib/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
2-
31
(function (global, factory) {
42
if (typeof define === "function" && define.amd) {
53
define(['module', 'exports', 'react'], factory);
@@ -33,7 +31,7 @@ function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.const
3331
}
3432
}
3533

36-
var _createClass = (function () {
34+
var _createClass = function () {
3735
function defineProperties(target, props) {
3836
for (var i = 0; i < props.length; i++) {
3937
var descriptor = props[i];
@@ -49,14 +47,14 @@ function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.const
4947
if (staticProps) defineProperties(Constructor, staticProps);
5048
return Constructor;
5149
};
52-
})();
50+
}();
5351

5452
function _possibleConstructorReturn(self, call) {
5553
if (!self) {
5654
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5755
}
5856

59-
return call && ((typeof call === 'undefined' ? 'undefined' : _typeof(call)) === "object" || typeof call === "function") ? call : self;
57+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
6058
}
6159

6260
function _inherits(subClass, superClass) {
@@ -75,7 +73,7 @@ function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.const
7573
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
7674
}
7775

78-
var TextTruncate = (function (_Component) {
76+
var TextTruncate = function (_Component) {
7977
_inherits(TextTruncate, _Component);
8078

8179
function TextTruncate() {
@@ -204,13 +202,13 @@ function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.const
204202
attrs,
205203
text
206204
),
207-
this.props.textTruncateChild
205+
this.props.text == text ? null : this.props.textTruncateChild
208206
);
209207
}
210208
}]);
211209

212210
return TextTruncate;
213-
})(_react.Component);
211+
}(_react.Component);
214212

215213
TextTruncate.propTypes = {
216214
text: _react2.default.PropTypes.string,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"homepage": "https://github.com/ShinyChang/react-text-truncate",
2727
"devDependencies": {
28-
"babel": "^6.5.2",
28+
"babel-cli": "^6.5.2",
2929
"babel-core": "^6.7.4",
3030
"babel-loader": "^6.2.4",
3131
"babel-plugin-add-module-exports": "^0.1.2",

src/TextTruncate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export default class TextTruncate extends Component {
124124
return (
125125
<div>
126126
<div {...attrs}>{text}</div>
127-
{this.props.textTruncateChild}
127+
{this.props.text == text ? null : this.props.textTruncateChild}
128128
</div>
129129
);
130130
}

0 commit comments

Comments
 (0)