@@ -96,6 +96,8 @@ function CSSJanus() {
96
96
var
97
97
// Tokens
98
98
temporaryToken = '`TMP`' ,
99
+ temporaryLtrToken = '`TMPLTR`' ,
100
+ temporaryRtlToken = '`TMPRTL`' ,
99
101
noFlipSingleToken = '`NOFLIP_SINGLE`' ,
100
102
noFlipClassToken = '`NOFLIP_CLASS`' ,
101
103
commentToken = '`COMMENT`' ,
@@ -139,6 +141,8 @@ function CSSJanus() {
139
141
suffixPattern = '(\\s*(?:!important\\s*)?[;}])' ,
140
142
// Regular expressions
141
143
temporaryTokenRegExp = / ` T M P ` / g,
144
+ temporaryLtrTokenRegExp = / ` T M P L T R ` / g,
145
+ temporaryRtlTokenRegExp = / ` T M P R T L ` / g,
142
146
commentRegExp = new RegExp ( commentPattern , 'gi' ) ,
143
147
noFlipSingleRegExp = new RegExp ( '(' + noFlipPattern + lookAheadNotOpenBracePattern + '[^;}]+;?)' , 'gi' ) ,
144
148
noFlipClassRegExp = new RegExp ( '(' + noFlipPattern + charsWithinSelectorPattern + '})' , 'gi' ) ,
@@ -148,6 +152,8 @@ function CSSJanus() {
148
152
rightRegExp = new RegExp ( nonLetterPattern + '(right)' + lookAheadNotLetterPattern + lookAheadNotClosingParenPattern + lookAheadNotOpenBracePattern , 'gi' ) ,
149
153
leftInUrlRegExp = new RegExp ( nonLetterPattern + '(left)' + lookAheadForClosingParenPattern , 'gi' ) ,
150
154
rightInUrlRegExp = new RegExp ( nonLetterPattern + '(right)' + lookAheadForClosingParenPattern , 'gi' ) ,
155
+ ltrDirSelector = / ( : d i r \( * ) l t r ( * \) ) / g,
156
+ rtlDirSelector = / ( : d i r \( * ) r t l ( * \) ) / g,
151
157
ltrInUrlRegExp = new RegExp ( nonLetterPattern + '(ltr)' + lookAheadForClosingParenPattern , 'gi' ) ,
152
158
rtlInUrlRegExp = new RegExp ( nonLetterPattern + '(rtl)' + lookAheadForClosingParenPattern , 'gi' ) ,
153
159
cursorEastRegExp = new RegExp ( nonLetterPattern + '([ns]?)e-resize' , 'gi' ) ,
@@ -348,9 +354,13 @@ function CSSJanus() {
348
354
if ( options . transformDirInUrl ) {
349
355
// Replace 'ltr' with 'rtl' and vice versa in background URLs
350
356
css = css
357
+ . replace ( ltrDirSelector , '$1' + temporaryLtrToken + '$2' )
358
+ . replace ( rtlDirSelector , '$1' + temporaryRtlToken + '$2' )
351
359
. replace ( ltrInUrlRegExp , '$1' + temporaryToken )
352
360
. replace ( rtlInUrlRegExp , '$1ltr' )
353
- . replace ( temporaryTokenRegExp , 'rtl' ) ;
361
+ . replace ( temporaryTokenRegExp , 'rtl' )
362
+ . replace ( temporaryLtrTokenRegExp , 'ltr' )
363
+ . replace ( temporaryRtlTokenRegExp , 'rtl' ) ;
354
364
}
355
365
if ( options . transformEdgeInUrl ) {
356
366
// Replace 'left' with 'right' and vice versa in background URLs
0 commit comments