File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -93,8 +93,29 @@ export default class SplitText {
93
93
this . safeCheckBalance = 0 ;
94
94
}
95
95
96
+ if ( byLines && ! byWords && ! byChars ) {
97
+ this . lines . forEach ( ( l ) => {
98
+ l . __words . forEach ( ( w ) => {
99
+ w . insertAdjacentHTML ( 'beforebegin' , w . textContent ) ;
100
+ w . remove ( ) ;
101
+ } ) ;
102
+ l . normalize ( ) ;
103
+ } ) ;
104
+ this . words . length = 0 ;
105
+ this . chars . length = 0 ;
106
+ }
107
+
96
108
if ( byChars ) {
97
- this . words . forEach ( ( w ) => this . chars . push ( ...this . splitElement ( w , 'char' , '' , false ) ) ) ;
109
+ this . words . forEach ( ( e ) => this . chars . push ( ...this . splitElement ( e , 'char' , '' , false ) ) ) ;
110
+ if ( ! byWords ) {
111
+ this . chars . forEach ( ( e ) => {
112
+ e . parentElement . insertAdjacentHTML ( 'beforebegin' , e . outerHTML ) ;
113
+ e . remove ( ) ;
114
+ } ) ;
115
+ this . chars = toArray ( element . getElementsByClassName ( 'char' ) ) ;
116
+ this . words . forEach ( ( e ) => e . remove ( ) ) ;
117
+ this . words . length = 0 ;
118
+ }
98
119
}
99
120
}
100
121
@@ -520,7 +541,7 @@ export default class SplitText {
520
541
} ) ;
521
542
522
543
lines . forEach ( ( line ) => {
523
- line . __words = line . getElementsByClassName ( 'word' ) ;
544
+ line . __words = toArray ( line . getElementsByClassName ( 'word' ) ) ;
524
545
line . __wordCount = line . __words . length ;
525
546
} ) ;
526
547
You can’t perform that action at this time.
0 commit comments