File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change 28
28
if ( typeof element !== 'object' ) return ;
29
29
30
30
var parent = element . parentNode ;
31
- var lines = parent . textContent . match ( / \r \n | \r | \n / g) ;
32
-
33
- lines = lines ? lines . length : 0 ;
34
-
35
- // fix for IE
36
- if ( isIE ( ) ) lines += 1 ;
31
+ var lines = getCountLines ( parent . textContent ) ;
37
32
38
33
if ( lines > 1 ) {
39
34
var l = '' ;
50
45
}
51
46
}
52
47
53
- function isIE ( userAgent ) {
54
- userAgent = userAgent || w . navigator . userAgent ;
55
- return userAgent . indexOf ( "MSIE " ) > - 1 || userAgent . indexOf ( "Trident/" ) > - 1 ;
48
+ function getCountLines ( text ) {
49
+ if ( text . length === 0 ) return 0 ;
50
+
51
+ var regExp = / \r \n | \r | \n / g;
52
+ var lines = text . match ( regExp ) ;
53
+ lines = lines ? lines . length : 0 ;
54
+
55
+ if ( ! text [ text . length - 1 ] . match ( regExp ) ) {
56
+ lines += 1 ;
57
+ }
58
+
59
+ return lines ;
56
60
}
57
61
} ( window ) ) ;
You can’t perform that action at this time.
0 commit comments