Skip to content

Commit f5e6064

Browse files
Replace includes for ie11 compatibility
According to the [MDN reference page](https://developer.mozilla.org /en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Br owser_compatibility) the `includes` method is not supported in Internet Explorer. `indexOf` can easily be used instead, which will provide compatibility with ie >= 11.
1 parent 9f7cbca commit f5e6064

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
_inherits(TextTruncate, _Component);
9090

9191
function TextTruncate() {
92-
var _Object$getPrototypeO;
92+
var _ref;
9393

9494
var _temp, _this, _ret;
9595

@@ -99,7 +99,7 @@
9999
args[_key] = arguments[_key];
100100
}
101101

102-
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(TextTruncate)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.onResize = function () {
102+
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = TextTruncate.__proto__ || Object.getPrototypeOf(TextTruncate)).call.apply(_ref, [this].concat(args))), _this), _this.onResize = function () {
103103
window.requestAnimationFrame(_this.update.bind(_this));
104104
}, _this.update = function () {
105105
_this.forceUpdate();
@@ -160,7 +160,8 @@
160160

161161
var childText = '';
162162
if (textTruncateChild && typeof textTruncateChild.type === 'string') {
163-
if (['span', 'a'].includes(textTruncateChild.type)) {
163+
var type = textTruncateChild.type;
164+
if (type.indexOf('span') >= 0 || type.indexOf('a') >= 0) {
164165
childText = textTruncateChild.props.children;
165166
}
166167
}

src/TextTruncate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export default class TextTruncate extends Component {
7575

7676
let childText = '';
7777
if (textTruncateChild && typeof textTruncateChild.type === 'string') {
78-
if (['span', 'a'].includes(textTruncateChild.type)) {
78+
let type = textTruncateChild.type;
79+
if (type.indexOf('span') >= 0 || type.indexOf('a') >= 0) {
7980
childText = textTruncateChild.props.children;
8081
}
8182
}

0 commit comments

Comments
 (0)