Comparing version 2.0.7 to 2.1.0
@@ -0,1 +1,4 @@ | ||
## 2.1.0 - 30 Nov. 2016 | ||
* Support CSS `background-position` edge offsets. | ||
### 2.0.7 - 16 Nov. 2016 | ||
@@ -2,0 +5,0 @@ * Fixes a bug in flipping backgrounds having url placed first (Fixes [#84](https://github.com/MohammadYounes/rtlcss/issues/84)). |
@@ -386,12 +386,16 @@ 'use strict' | ||
'cache': null, | ||
'flip': function (value, context) { | ||
'flip': function (value, context, isPosition) { | ||
var state = util.saveTokens(value, true) | ||
var parts = state.value.match(this.cache.match) | ||
if (parts && parts.length > 0) { | ||
parts[0] = parts[0] === '0' | ||
? '100%' | ||
: (parts[0].match(this.cache.percent) | ||
? context.util.complement(parts[0]) | ||
: context.util.swapLeftRight(parts[0])) | ||
state.value = state.value.replace(this.cache.match, function () { return parts.shift() }) | ||
if (isPosition && parts.length >= 3) { | ||
state.value = util.swapLeftRight(state.value) | ||
} else { | ||
parts[0] = parts[0] === '0' | ||
? '100%' | ||
: (parts[0].match(this.cache.percent) | ||
? context.util.complement(parts[0]) | ||
: context.util.swapLeftRight(parts[0])) | ||
state.value = state.value.replace(this.cache.match, function () { return parts.shift() }) | ||
} | ||
} | ||
@@ -414,3 +418,3 @@ return util.restoreTokens(state) | ||
this.cache = { | ||
'match': context.util.regex(['position', 'percent', 'length', 'calc'], 'i'), | ||
'match': context.util.regex(['position', 'percent', 'length', 'calc'], 'ig'), | ||
'percent': context.util.regex(['calc', 'percent'], 'i'), | ||
@@ -425,5 +429,7 @@ 'gradient': /gradient$/i, | ||
var parts = funcSafe.value.split(',') | ||
if (prop.toLowerCase() !== 'background-image') { | ||
var lprop = prop.toLowerCase() | ||
if (lprop !== 'background-image') { | ||
var isPosition = lprop === 'background-position' | ||
for (var x = 0; x < parts.length; x++) { | ||
parts[x] = this.flip(parts[x], context) | ||
parts[x] = this.flip(parts[x], context, isPosition) | ||
} | ||
@@ -430,0 +436,0 @@ } |
{ | ||
"author": "Mohammad Younes", | ||
"name": "rtlcss", | ||
"version": "2.0.7", | ||
"version": "2.1.0", | ||
"description": "Framework for transforming cascading style sheets (CSS) from left-to-right (LTR) to right-to-left (RTL)", | ||
@@ -6,0 +6,0 @@ "homepage": "http://rtlcss.com/", |
@@ -27,3 +27,3 @@ module.exports = [ | ||
{ | ||
'should': 'Should swap left with right', | ||
'should': 'Should mirror background-position', | ||
'expected': 'div {background-position:right 75%, left top;}', | ||
@@ -34,3 +34,3 @@ 'input': 'div {background-position:left 75%, right top;}', | ||
{ | ||
'should': 'Should swap left with right wit calc', | ||
'should': 'Should mirror background-position (calc)', | ||
'expected': 'div {background-position:right -ms-calc(30% + 50px), left top;}', | ||
@@ -59,3 +59,3 @@ 'input': 'div {background-position:left -ms-calc(30% + 50px), right top;}', | ||
{ | ||
'should': 'Should swap left with right: position-x', | ||
'should': 'Should mirror position-x', | ||
'expected': 'div {background-position-x:right, left;}', | ||
@@ -66,2 +66,8 @@ 'input': 'div {background-position-x:left, right;}', | ||
{ | ||
'should': 'Should mirror position-x (calc)', | ||
'expected': 'div {background-position-x:calc(100% - (30% + 50px)), calc(100% - (50px * 5));}', | ||
'input': 'div {background-position-x:calc(30% + 50px), calc(50px * 5);}', | ||
'reversable': false | ||
}, | ||
{ | ||
'should': 'Should keep as is: position-x', | ||
@@ -71,3 +77,15 @@ 'expected': 'div {background-position-x:100px, 0px;}', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror background-position edge offsets (4 values)', | ||
'expected': 'div {background-position: left 5px bottom 5px, bottom 15px right 15px;}', | ||
'input': 'div {background-position: right 5px bottom 5px, bottom 15px left 15px;}', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror background-position edge offsets (3 values)', | ||
'expected': 'div {background-position: left 5px bottom, top 15px right;}', | ||
'input': 'div {background-position: right 5px bottom, top 15px left;}', | ||
'reversable': true | ||
} | ||
] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131857
3040