File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
test/htmlx2jsx/samples/editing-mustache Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,9 @@ const possibleOperatorOrPropertyAccess = [
128
128
'&' ,
129
129
'^' ,
130
130
'|' ,
131
- ','
131
+ ',' ,
132
+ '+' ,
133
+ '-'
132
134
] ;
133
135
134
136
function blankPossiblyErrorOperatorOrPropertyAccess ( htmlx : string ) {
@@ -141,8 +143,18 @@ function blankPossiblyErrorOperatorOrPropertyAccess(htmlx: string) {
141
143
while ( backwardIndex > lastIndex ) {
142
144
const char = htmlx . charAt ( backwardIndex ) ;
143
145
if ( possibleOperatorOrPropertyAccess . includes ( char ) ) {
144
- htmlx =
145
- htmlx . substring ( 0 , backwardIndex ) + ' ' + htmlx . substring ( backwardIndex + 1 ) ;
146
+ const previous = backwardIndex - 1 ;
147
+ const isPlusOrMinus = char === '+' || char === '-' ;
148
+ const isIncrementOrDecrement = isPlusOrMinus && htmlx . charAt ( previous ) === char ;
149
+ const start = isIncrementOrDecrement ? previous : backwardIndex ;
150
+ const replacement = isIncrementOrDecrement ? ' ' : ' ' ;
151
+
152
+ if ( ! isPlusOrMinus ) {
153
+ htmlx =
154
+ htmlx . substring ( 0 , start ) +
155
+ replacement +
156
+ htmlx . substring ( backwardIndex + 1 ) ;
157
+ }
146
158
} else if ( ! / \s / . test ( char ) ) {
147
159
break ;
148
160
}
Original file line number Diff line number Diff line change 1
1
< > { abc . }
2
2
{ abc ?. }
3
- { abc ?} </ >
3
+ { abc ?}
4
+ { a + } </ >
Original file line number Diff line number Diff line change 1
1
{abc . }
2
2
{abc ?. }
3
3
{abc ? }
4
+ {a+}
You can’t perform that action at this time.
0 commit comments