Socket
Socket
Sign inDemoInstall

rtlcss

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rtlcss - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

39

lib/config.js

@@ -19,8 +19,35 @@ function main(options, rules, declarations, properties) {

addKey('autoRename', true);
addKey('swapLeftRightInUrl', true);
addKey('swapLtrRtlInUrl', true);
addKey('swapWestEastInUrl', true);
addKey('stringMap', []);
addKey('greedy', false);
addKey('minify', false);
//default strings map
//backward comptabile
var urlFlag = optionOrDefault('swapLeftRightInUrl', true);
if (!config.stringMap.some(function (map) { return map.name == 'left-right'; }))
config.stringMap.push({
'name':'left-right',
'search': ['left', 'Left', 'LEFT'],
'replace': ['right', 'Right', 'RIGHT'],
options: { scope: urlFlag ? '*' : 'selector', ignoreCase: false }
});
urlFlag = optionOrDefault('swapLtrRtlInUrl', true)
if (!config.stringMap.some(function (map) { return map.name == 'ltr-rtl'; }))
config.stringMap.push({
'name':'ltr-rtl',
'search': ['ltr', 'Ltr', 'LTR'],
'replace': ['rtl', 'Rtl', 'RTL'],
options: { scope: urlFlag ? '*' : 'selector', ignoreCase: false }
});
urlFlag = optionOrDefault('swapWestEastInUrl', true)
if (!config.stringMap.some(function (map) { return map.name == 'west-east'; }))
config.stringMap.push({
'name':'west-east',
'search': ['west', 'West', 'WEST'],
'replace': ['east', 'East', 'EAST'],
options: { scope: urlFlag ? '*' : 'selector', ignoreCase: false }
});
if (config.minify)

@@ -36,3 +63,3 @@ config.preserveComments = config.preserveDirectives = false;

if(rule.important)
config.instructions.rules.splice(0, 0, rule);
config.instructions.rules.unshift(rule);
else

@@ -46,3 +73,3 @@ config.instructions.rules.push(rule)

if(decl.important)
config.instructions.declarations.splice(0, 0, decl);
config.instructions.declarations.unshift(decl);
else

@@ -56,3 +83,3 @@ config.instructions.declarations.push(decl);

if (prop.important)
config.instructions.properties.splice(0, 0, prop);
config.instructions.properties.unshift(prop);
else

@@ -59,0 +86,0 @@ config.instructions.properties.push(prop);

14

lib/prop.js

@@ -199,8 +199,3 @@ function main(configuration) {

else if (item.match(/^url/i)) {
if (config.swapLeftRightInUrl)
item = util.swapLeftRight(item);
if (config.swapLtrRtlInUrl)
item = util.swapLtrRtl(item);
if (config.swapWestEastInUrl)
item = util.swapWestEast(item);
item = util.applyStringMap(item, false, true);
}

@@ -254,8 +249,3 @@

if (item.match(/^url/i)) {
if (config.swapLeftRightInUrl)
item = util.swapLeftRight(item);
if (config.swapLtrRtlInUrl)
item = util.swapLtrRtl(item);
if (config.swapWestEastInUrl)
item = util.swapWestEast(item);
item = util.applyStringMap(item, false, true);
}

@@ -262,0 +252,0 @@

@@ -70,4 +70,6 @@ (function() {

if (config.autoRename && flipped == 0)
rule.selector = util.swapLeftRight(util.swapLtrRtl(util.swapWestEast(rule.selector)));
if (config.autoRename && flipped == 0) {
rule.selector = util.applyStringMap(rule.selector, true, false);
}
return;

@@ -78,11 +80,3 @@ });

css.eachAtRule(function (atRule) {
if(config.swapLeftRightInUrl){
atRule.params = util.swapLeftRight(atRule.params);
}
if(config.swapLtrRtlInUrl){
atRule.params = util.swapLtrRtl(atRule.params);
}
if(config.swapWestEastInUrl){
atRule.params = util.swapWestEast(atRule.params);
}
atRule.params = util.applyStringMap(atRule.params, false, true);
if(config.minify){

@@ -89,0 +83,0 @@ atRule.before = '';

@@ -17,3 +17,3 @@ function main(configuration) {

"action": function (rule) {
var renamed = util.swapLeftRight(util.swapLtrRtl(util.swapWestEast(rule.selector)));
var renamed = util.applyStringMap(rule.selector, true, false);
if (renamed != rule.selector) {

@@ -20,0 +20,0 @@ rule.selector = renamed;

function main(configuration) {
var config = configuration;
var chalk = require('chalk');
var success = chalk.green;
var info = chalk.yellow;
var REPLACEMENT_CHARACTER = '\uFFFD';
var REGEX_COMMENT = /\/\*(.|\s)*?\*\//gm;
chalk = require('chalk'),
success = chalk.green,
info = chalk.cyan,
REPLACEMENT_CHARACTER = '\uFFFD',
REGEX_COMMENT = /\/\*(.|\s)*?\*\//gm,
DEFAULT_STRING_MAP_OPTIONS = { scope: '*', ignoreCase: true },
compare = function (what, to, ignoreCase) {
if (ignoreCase)
return what.toLowerCase() === to.toLowerCase();
return what === to;
},
extend = function (dest, src) {
if (typeof dest === 'undefined' || typeof dest !== 'object')
dest = {};
for (var prop in src) {
if (!dest.hasOwnProperty(prop)) {
dest[prop] = src[prop];
}
}
return dest;
};
var util =

@@ -43,7 +58,13 @@ {

},
swap: function (value, a, b) {
swap: function (value, a, b, options) {
var expr = a + "|" + b;
if (!config.greedy)
expr = "\\b(" + expr + ")\\b";
return value.replace(new RegExp(expr, "img"), function (m) { return m.toLowerCase() == a ? b : a; });
options = options || DEFAULT_STRING_MAP_OPTIONS;
var greedy = options.hasOwnProperty('greedy') ? options.greedy : config.greedy;
if (!greedy)
expr = "\\b(" + expr + ")\\b";
var flags = options.ignoreCase ? "img" : "mg";
return value.replace(new RegExp(expr, flags), function (m) { return compare(m, a, options.ignoreCase) ? b : a; });
},

@@ -56,4 +77,23 @@ swapLeftRight: function (value) {

},
swapWestEast: function (value) {
return this.swap(value, "west", "east");
applyStringMap: function (value, inSelector, inUrl) {
var result = value;
for (var x = 0; x < config.stringMap.length; x++) {
var map = config.stringMap[x];
var options = extend(map.options, DEFAULT_STRING_MAP_OPTIONS);
if (options.scope === '*' || (inSelector && options.scope == 'selector') || (inUrl && options.scope == 'url')) {
this.log(info('Applying string map: ' + (map.name || "<unknown>") + '.'));
if (map.search instanceof Array && map.replace instanceof Array) {
for (var mapIndex = 0; mapIndex < map.search.length; mapIndex++) {
result = util.swap(result, map.search[mapIndex], map.replace[mapIndex % map.search.length], options);
}
} else {
result = util.swap(result, map.search, map.replace, options);
}
}
}
return result;
},

@@ -60,0 +100,0 @@ comments: [],

{
"author": "Mohammad Younes",
"name": "rtlcss",
"version": "1.2.0",
"version": "1.3.0",
"description": "Framework for transforming cascading style sheets (CSS) from left-to-right (LTR) to right-to-left (RTL)",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/MohammadYounes/rtlcss/issues?state=open",

@@ -98,3 +98,3 @@ [![GitHub version](https://badge.fury.io/gh/MohammadYounes%2Frtlcss.svg)](http://badge.fury.io/gh/MohammadYounes%2Frtlcss)

When RTLing a CSS document, there are cases where its impossible to know if the property value should be mirrored or not! If the rule selector need to be changed! Or a none directional property have to be updated. In such cases, RTLCSS provides processing directives in the form of CSS comments ```/*rtl:...*/```:
When RTLing a CSS document, there are cases where its impossible to know if the property value should be mirrored or not! If the rule selector need to be changed! Or a none directional property have to be updated. In such cases, RTLCSS provides processing directives in the form of CSS comments, both standard ```/*rtl:...*/``` and special/important ```/*!rtl:...*/``` notations are supported.

@@ -201,6 +201,80 @@ Two sets of processing directives are available, on Rule and Declaration level.

|**`autoRename`** | `true` | Applies to CSS rules containing no directional properties, it will update the selector by swapping ***left***, ***right***, ***ltr***, ***rtl***, ***west*** and ***east***.([more info](https://github.com/MohammadYounes/rtlcss/wiki/Why-Auto-Rename%3F))
|**`greedy`** | `false` | Forces selector renaming and url updates to respect word boundaries, for example: `.ultra { ...}` will not be changed to `.urtla {...}`
|**`greedy`** | `false` | A `false` value forces selector renaming and url updates to respect word boundaries, for example: `.ultra { ...}` will not be changed to `.urtla {...}`
|**`stringMap`** | see [String Map](#string-map-array) | Applies to string replacement in renamed selectors and updated URLs
|**`enableLogging`** | `false` | Outputs information about mirrored declarations to the console.
|**`minify`** | `false` | Minifies output CSS, when set to `true` both `preserveDirectives` and `preserveComments` will be set to `false` .
### stringMap (Array)
String map is a collection of map objects, each defines mapping between directional strings, it is used in selectors renaming and URL updates. The following is the default string map:
```javascript
[
{
'name' : 'left-right',
'search' : ['left', 'Left', 'LEFT'],
'replace' : ['right', 'Right', 'RIGHT'],
'options' : {
'scope': options.swapWestEastInUrl ? '*' : 'selector',
'ignoreCase': false
}
},
{
'name' : 'ltr-rtl',
'search' : ['ltr', 'Ltr', 'LTR'],
'replace' : ['rtl', 'Rtl', 'RTL'],
'options' : {
'scope': options.swapWestEastInUrl ? '*' : 'selector',
'ignoreCase': false
}
},
{
'name':'west-east',
'search': ['west', 'West', 'WEST'],
'replace': ['east', 'East', 'EAST'],
'options' : {
'scope': options.swapWestEastInUrl ? '*' : 'selector',
'ignoreCase': false
}
}
]
```
To override any of the default maps, just add your own with the same name. A map object consists of the following:
| Property | Type | Description
|:--------------|:----------|:--------------
| **`name`** | `string` | Name of the map object
| **`search`** | `string` or `Array` | The string or list of strings to search for or replace with.
| **`replace`** | `string` or `Array` | The string or list of strings to search for or replace with.
| **`options`** | `object` | Defines map options.
The map `options` is optional, and consists of the following:
| Property | Type | Default | Description
|:--------------|:----------|:--------------|:--------------
| **`scope`** | `string` | `*` | Defines the scope in which this map is allowed, 'selector' for selector renaming, 'url' for url updates and '*' for both.
| **`ignoreCase`** | `Boolean` | `true` | Indicates if the search is case-insensitive or not.
| **`greedy`** | `Boolean` | reverts to `options.greedy` | A false value forces selector renaming and url updates to respect word boundaries.
**Example**
```javascript
// a simple map, for swapping "prev" with "next" and vice versa.
{
"name" : "prev-next",
"search" : "prev",
"replace" : "next"
}
// a more detailed version, considering the convention used in the authored CSS document.
{
"name" : "prev-next",
"search" : ["prev", "Prev", "PREV"],
"replace" : ["next", "Next", "NEXT"],
options : {"ignoreCase":false}
}
```
### rules (array)

@@ -269,3 +343,3 @@

| **`name`** | `string` | Name of the PI (used in logging).
| **`expr`** | `RegExp` | Regular expression object that will be matched against the declaration raw value.
| **`expr`** | `RegExp` | Regular expression object that will be matched against the declaration property name.
| **`important`** | `boolean` | Controls whether to insert the PI at the start or end of the declarations PIs list.

@@ -294,5 +368,8 @@ | **`action`** | `function` | The action to be called when a match is found, it will be passed a `prop` (string holding the CSS property name) and `value` (string holding the CSS property raw value). If `options.preserveComments == true`, comments in the raw value will be replaced by the Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD) &#xfffd; (this is to simplify pattern matching). The function is expected to return an object containing the modified version of the property and its value.

## Release Notes
* **v1.3.0** [28 Sep. 2014]
* New feature - String Maps. Add your own set of swappable strings, for example (prev/next).
* Preserves lowercase, UPPERCASE and Capitalization when swapping ***left***, ***right***, ***ltr***, ***rtl***, ***west*** and ***east***.
* **v1.2.0** [26 Sep. 2014]
* Support !important comments for directives (enbles flipping minified stylesheets).
* Support !important comments for directives (enables flipping minified stylesheets).

@@ -299,0 +376,0 @@ * **v1.1.0** [26 Sep. 2014]

@@ -6,80 +6,80 @@ var assert = require("assert");

{
'should' : 'Should treat 0 as 0%',
'expected' : '.banner { background: 100% top url(topbanner.png) #00D repeat-y fixed; }',
'input' : '.banner { background: 0 top url(topbanner.png) #00D repeat-y fixed; }',
'reversable' : false
'should': 'Should treat 0 as 0%',
'expected': '.banner { background: 100% top url(topbanner.png) #00D repeat-y fixed; }',
'input': '.banner { background: 0 top url(topbanner.png) #00D repeat-y fixed; }',
'reversable': false
},
{
'should' : 'Should complement percentage horizontal position',
'expected' : '.banner { background: 81% top url(topbanner.png) #00D repeat-y fixed; }',
'input' : '.banner { background: 19% top url(topbanner.png) #00D repeat-y fixed; }',
'reversable' : true
'should': 'Should complement percentage horizontal position',
'expected': '.banner { background: 81% top url(topbanner.png) #00D repeat-y fixed; }',
'input': '.banner { background: 19% top url(topbanner.png) #00D repeat-y fixed; }',
'reversable': true
},
{
'should' : 'Should mirror keyword horizontal position',
'expected' : '.banner { background: right top url(topbanner.png) #00D repeat-y fixed; }',
'input' : '.banner { background: left top url(topbanner.png) #00D repeat-y fixed; }',
'should': 'Should mirror keyword horizontal position',
'expected': '.banner { background: right top url(topbanner.png) #00D repeat-y fixed; }',
'input': '.banner { background: left top url(topbanner.png) #00D repeat-y fixed; }',
'reversable': true
},
{
'should' : 'Should swap left with right in url',
'expected' : '.banner { background: 10px top url(top-left-banner.png) #00D repeat-y fixed; }',
'input' : '.banner { background: 10px top url(top-right-banner.png) #00D repeat-y fixed; }',
'should': 'Should swap left with right in url',
'expected': '.banner { background: 10px top url(top-left-banner.png) #00D repeat-y fixed; }',
'input': '.banner { background: 10px top url(top-right-banner.png) #00D repeat-y fixed; }',
'reversable': true
},
{
'should' : 'Should swap ltr with rtl in url',
'expected' : '.banner { background: 10px top url(rtl-banner.png) #00D repeat-y fixed; }',
'input' : '.banner { background: 10px top url(ltr-banner.png) #00D repeat-y fixed; }',
'should': 'Should swap ltr with rtl in url',
'expected': '.banner { background: 10px top url(rtl-banner.png) #00D repeat-y fixed; }',
'input': '.banner { background: 10px top url(ltr-banner.png) #00D repeat-y fixed; }',
'reversable': true
},
{
'should' : 'Should swap west with east in url',
'expected' : '.banner { background: 10px top url(east-banner.png) #00D repeat-y fixed; }',
'input' : '.banner { background: 10px top url(west-banner.png) #00D repeat-y fixed; }',
'should': 'Should swap west with east in url',
'expected': '.banner { background: 10px top url(east-banner.png) #00D repeat-y fixed; }',
'input': '.banner { background: 10px top url(west-banner.png) #00D repeat-y fixed; }',
'reversable': true
},
{
'should' : 'Should not swap bright:bleft, ultra:urtla, westing:easting',
'expected' : '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }',
'input' : '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }',
'reversable': true
},
'should': 'Should not swap bright:bleft, ultra:urtla, westing:easting',
'expected': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }',
'input': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }',
'reversable': true
},
{
'should' : 'Should swap bright:bleft, ultra:urtla, westing:easting (greedy)',
'expected' : '.banner { background: 10px top url(urtla/easting/bleft.png) #00D repeat-y fixed; }',
'input' : '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }',
'reversable': true,
'options' : {'greedy':true}
},
'should': 'Should swap bright:bleft, ultra:urtla, westing:easting (greedy)',
'expected': '.banner { background: 10px top url(urtla/easting/bleft.png) #00D repeat-y fixed; }',
'input': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }',
'reversable': true,
'options': { 'greedy': true }
},
],
'Background Image:': [
{
'should' : 'Should swap left with right in url',
'expected' : 'div { background-image: url(images/left.png), url(images/right.png);}',
'input' : 'div { background-image: url(images/right.png), url(images/left.png);}',
'should': 'Should swap left with right in url',
'expected': 'div { background-image: url(images/left.png), url(images/right.png);}',
'input': 'div { background-image: url(images/right.png), url(images/left.png);}',
'reversable': true
},
{
'should' : 'Should swap ltr with rtl in url',
'expected' : 'div { background-image: url(images/ltr.png), url(images/rtl.png);}',
'input' : 'div { background-image: url(images/rtl.png), url(images/ltr.png);}',
'should': 'Should swap ltr with rtl in url',
'expected': 'div { background-image: url(images/ltr.png), url(images/rtl.png);}',
'input': 'div { background-image: url(images/rtl.png), url(images/ltr.png);}',
'reversable': true
},
{
'should' : 'Should swap west with east in url',
'expected' : 'div { background-image: url(images/west.png), url(images/east.png);}',
'input' : 'div { background-image: url(images/east.png), url(images/west.png);}',
'should': 'Should swap west with east in url',
'expected': 'div { background-image: url(images/west.png), url(images/east.png);}',
'input': 'div { background-image: url(images/east.png), url(images/west.png);}',
'reversable': true
},
{
'should' : 'Should not negate color value for linear gradient',
'expected' : 'div { background-image: linear-gradient(rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.3) 100%);}',
'input' : 'div { background-image: linear-gradient(rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.3) 100%);}',
'should': 'Should not negate color value for linear gradient',
'expected': 'div { background-image: linear-gradient(rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.3) 100%);}',
'input': 'div { background-image: linear-gradient(rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.3) 100%);}',
'reversable': true
},
{
'should' : 'Should negate angle value for linear gradient',
'expected' : 'div { background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%);}',
'input' : 'div { background-image: linear-gradient(-135deg, rgba(255, 255, 255, .15) 25%, transparent 25%);}',
'should': 'Should negate angle value for linear gradient',
'expected': 'div { background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%);}',
'input': 'div { background-image: linear-gradient(-135deg, rgba(255, 255, 255, .15) 25%, transparent 25%);}',
'reversable': true

@@ -90,17 +90,17 @@ }

{
'should' : 'Should complement percentage horizontal position ',
'expected' : 'div {background-position:100% 75%;}',
'input' : 'div {background-position:0 75%;}',
'should': 'Should complement percentage horizontal position ',
'expected': 'div {background-position:100% 75%;}',
'input': 'div {background-position:0 75%;}',
'reversable': false
},
{
'should' : 'Should complement percentage horizontal position ',
'expected' : 'div {background-position:81% 75%, 11% top;}',
'input' : 'div {background-position:19% 75%, 89% top;}',
'should': 'Should complement percentage horizontal position ',
'expected': 'div {background-position:81% 75%, 11% top;}',
'input': 'div {background-position:19% 75%, 89% top;}',
'reversable': true
},
{
'should' : 'Should swap left with right',
'expected' : 'div {background-position:right 75%, left top;}',
'input' : 'div {background-position:left 75%, right top;}',
'should': 'Should swap left with right',
'expected': 'div {background-position:right 75%, left top;}',
'input': 'div {background-position:left 75%, right top;}',
'reversable': true

@@ -133,61 +133,61 @@ },

],
'Mirrored Properties:': [
'Mirrored Properties:': [
{
'should' : 'Should mirror property name: border-top-right-radius',
'expected' : 'div { border-top-left-radius:15px; }',
'input' : 'div { border-top-right-radius:15px; }',
'should': 'Should mirror property name: border-top-right-radius',
'expected': 'div { border-top-left-radius:15px; }',
'input': 'div { border-top-right-radius:15px; }',
'reversable': true
},
{
'should' : 'Should mirror property name: border-bottom-right-radius',
'expected' : 'div { border-bottom-left-radius:15px; }',
'input' : 'div { border-bottom-right-radius:15px; }',
'should': 'Should mirror property name: border-bottom-right-radius',
'expected': 'div { border-bottom-left-radius:15px; }',
'input': 'div { border-bottom-right-radius:15px; }',
'reversable': true
},
{
'should' : 'Should mirror property name: border-left',
'expected' : 'div { border-right:1px solid black; }',
'input' : 'div { border-left:1px solid black; }',
'should': 'Should mirror property name: border-left',
'expected': 'div { border-right:1px solid black; }',
'input': 'div { border-left:1px solid black; }',
'reversable': true
},
{
'should' : 'Should mirror property name: border-left-color',
'expected' : 'div { border-right-color:black; }',
'input' : 'div { border-left-color:black; }',
'should': 'Should mirror property name: border-left-color',
'expected': 'div { border-right-color:black; }',
'input': 'div { border-left-color:black; }',
'reversable': true
},
{
'should' : 'Should mirror property name: border-left-style',
'expected' : 'div { border-right-style:solid; }',
'input' : 'div { border-left-style:solid; }',
'should': 'Should mirror property name: border-left-style',
'expected': 'div { border-right-style:solid; }',
'input': 'div { border-left-style:solid; }',
'reversable': true
},
{
'should' : 'Should mirror property name: border-left-width',
'expected' : 'div { border-right-width:1em; }',
'input' : 'div { border-left-width:1em; }',
'should': 'Should mirror property name: border-left-width',
'expected': 'div { border-right-width:1em; }',
'input': 'div { border-left-width:1em; }',
'reversable': true
},
{
'should' : 'Should mirror property name: left',
'expected' : 'div { right:auto; }',
'input' : 'div { left:auto; }',
'should': 'Should mirror property name: left',
'expected': 'div { right:auto; }',
'input': 'div { left:auto; }',
'reversable': true
},
{
'should' : 'Should mirror property name: margin-left',
'expected' : 'div { margin-right:2em; }',
'input' : 'div { margin-left:2em; }',
'should': 'Should mirror property name: margin-left',
'expected': 'div { margin-right:2em; }',
'input': 'div { margin-left:2em; }',
'reversable': true
},
{
'should' : 'Should mirror property name: padding-left',
'expected' : 'div { padding-right:2em; }',
'input' : 'div { padding-left:2em; }',
'should': 'Should mirror property name: padding-left',
'expected': 'div { padding-right:2em; }',
'input': 'div { padding-left:2em; }',
'reversable': true
},
},
{
'should' : 'Should mirror property name: nav-left',
'expected' : 'div { nav-right:#b4; }',
'input' : 'div { nav-left:#b4; }',
'should': 'Should mirror property name: nav-left',
'expected': 'div { nav-right:#b4; }',
'input': 'div { nav-left:#b4; }',
'reversable': true

@@ -198,493 +198,493 @@ }

{
'should' : 'Should mirror property value: clear',
'expected' : 'div { clear:right; }',
'input' : 'div { clear:left; }',
'should': 'Should mirror property value: clear',
'expected': 'div { clear:right; }',
'input': 'div { clear:left; }',
'reversable': true
},
{
'should' : 'Should mirror property value: direction',
'expected' : 'div { direction:ltr; }',
'input' : 'div { direction:rtl; }',
'should': 'Should mirror property value: direction',
'expected': 'div { direction:ltr; }',
'input': 'div { direction:rtl; }',
'reversable': true
},
{
'should' : 'Should mirror property value: float',
'expected' : 'div { float:right; }',
'input' : 'div { float:left; }',
'reversable': true
},
'should': 'Should mirror property value: float',
'expected': 'div { float:right; }',
'input': 'div { float:left; }',
'reversable': true
},
{
'should' : 'Should mirror property value: text-align',
'expected' : 'div { text-align:right; }',
'input' : 'div { text-align:left; }',
'reversable': true
},
'should': 'Should mirror property value: text-align',
'expected': 'div { text-align:right; }',
'input': 'div { text-align:left; }',
'reversable': true
},
{
'should' : 'Should mirror property value: cursor nw',
'expected' : 'div { cursor:nw-resize; }',
'input' : 'div { cursor:ne-resize; }',
'reversable': true
},
'should': 'Should mirror property value: cursor nw',
'expected': 'div { cursor:nw-resize; }',
'input': 'div { cursor:ne-resize; }',
'reversable': true
},
{
'should' : 'Should mirror property value: cursor sw',
'expected' : 'div { cursor:sw-resize; }',
'input' : 'div { cursor:se-resize; }',
'reversable': true
},
'should': 'Should mirror property value: cursor sw',
'expected': 'div { cursor:sw-resize; }',
'input': 'div { cursor:se-resize; }',
'reversable': true
},
{
'should' : 'Should mirror property value: cursor nesw',
'expected' : 'div { cursor:nesw-resize; }',
'input' : 'div { cursor:nwse-resize; }',
'reversable': true
},
'should': 'Should mirror property value: cursor nesw',
'expected': 'div { cursor:nesw-resize; }',
'input': 'div { cursor:nwse-resize; }',
'reversable': true
},
{
'should' : 'Should keep property value as is: cursor ns',
'expected' : 'div { cursor:ns-resize; }',
'input' : 'div { cursor:ns-resize; }',
'reversable': false
},
'should': 'Should keep property value as is: cursor ns',
'expected': 'div { cursor:ns-resize; }',
'input': 'div { cursor:ns-resize; }',
'reversable': false
},
{
'should' : 'Should swap left,ltr,west in url: cursor',
'expected' : '.foo { cursor: url(right.cur), url(rtl.cur), url(east.cur), se-resize, auto }',
'input' : '.foo { cursor: url(left.cur), url(ltr.cur), url(west.cur), sw-resize, auto }',
'reversable': true
},
'should': 'Should swap left,ltr,west in url: cursor',
'expected': '.foo { cursor: url(right.cur), url(rtl.cur), url(east.cur), se-resize, auto }',
'input': '.foo { cursor: url(left.cur), url(ltr.cur), url(west.cur), sw-resize, auto }',
'reversable': true
},
{
'should' : 'Should mirror property value: transition',
'expected' : '.foo { transition: right .3s ease .1s, left .3s ease .1s, margin-right .3s ease, margin-left .3s ease, padding-right .3s ease, padding-left .3s ease}',
'input' : '.foo { transition: left .3s ease .1s, right .3s ease .1s, margin-left .3s ease, margin-right .3s ease, padding-left .3s ease, padding-right .3s ease}',
'reversable': true
},
'should': 'Should mirror property value: transition',
'expected': '.foo { transition: right .3s ease .1s, left .3s ease .1s, margin-right .3s ease, margin-left .3s ease, padding-right .3s ease, padding-left .3s ease}',
'input': '.foo { transition: left .3s ease .1s, right .3s ease .1s, margin-left .3s ease, margin-right .3s ease, padding-left .3s ease, padding-right .3s ease}',
'reversable': true
},
{
'should' : 'Should mirror property value: transition-property',
'expected' : '.foo { transition-property: right; }',
'input' : '.foo { transition-property: left; }',
'reversable': true
},
'should': 'Should mirror property value: transition-property',
'expected': '.foo { transition-property: right; }',
'input': '.foo { transition-property: left; }',
'reversable': true
},
],
'Mirrored Values (N Value Syntax):': [
{
'should' : 'Should mirror property value: border-radius (4 values)',
'expected' : 'div { border-radius: 40px 10px 10px 40px; }',
'input' : 'div { border-radius: 10px 40px 40px 10px; }',
'reversable': true
},
{
'should' : 'Should mirror property value: border-radius (3 values)',
'expected' : 'div { border-radius: 40px 10px 40px 40px; }',
'input' : 'div { border-radius: 10px 40px 40px; }',
'reversable': false
},
{
'should' : 'Should mirror property value: border-radius (2 values)',
'expected' : 'div { border-radius: 40px 10px; }',
'input' : 'div { border-radius: 10px 40px; }',
'reversable': true
},
{
'should' : 'Should mirror property value: border-radius (4 values - double)',
'expected' : 'div { border-radius: 40px 10px 10px 40px / 4em 1em 1em 4em; }',
'input' : 'div { border-radius: 10px 40px 40px 10px / 1em 4em 4em 1em; }',
'reversable': true
},
{
'should' : 'Should mirror property value: border-radius (3 values - double)',
'expected' : 'div { border-radius: 40px 10px 40px 40px /4em 1em 4em 3em; }',
'input' : 'div { border-radius: 10px 40px 40px / 1em 4em 3em; }',
'reversable': false
},
{
'should' : 'Should mirror property value: border-radius (2 values- double)',
'expected' : 'div { border-radius: 40px 10px / 2em 1em; }',
'input' : 'div { border-radius: 10px 40px / 1em 2em; }',
'reversable': true
},
{
'should' : 'Should mirror property value: border-width',
'expected' : 'div { border-width: 1px 4px 3px 2px; }',
'input' : 'div { border-width: 1px 2px 3px 4px; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-width (none length)',
'expected': 'div { border-width: thin medium thick none; }',
'input': 'div { border-width: thin none thick medium; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-style (4 values)',
'expected': 'div { border-style: none dashed dotted solid; }',
'input': 'div { border-style: none solid dotted dashed; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-color (4 values)',
'expected': 'div { border-color: rgba(255, 255, 255, 1) rgb( 0, 0, 0) #000 hsla(0, 100%, 50%, 1); }',
'input': 'div { border-color: rgba(255, 255, 255, 1) hsla(0, 100%, 50%, 1) #000 rgb( 0, 0, 0); }',
'reversable': true
},
{
'should': 'Should not mirror property value: border-color (3 values)',
'expected': 'div { border-color: #000 rgb( 0, 0, 0) hsla(0, 100%, 50%, 1); }',
'input': 'div { border-color: #000 rgb( 0, 0, 0) hsla(0, 100%, 50%, 1); }',
'reversable': false
},
{
'should': 'Should not mirror property value: border-color (2 values)',
'expected': 'div { border-color:rgb( 0, 0, 0) hsla(0, 100%, 50%, 1); }',
'input': 'div { border-color:rgb( 0, 0, 0) hsla(0, 100%, 50%, 1); }',
'reversable': false
},
{
'should' : 'Should mirror property value: margin',
'expected' : 'div { margin: 1px auto 3px 2px; }',
'input' : 'div { margin: 1px 2px 3px auto; }',
'reversable': true
},
{
'should' : 'Should mirror property value: padding',
'expected' : 'div { padding: 1px 4px 3px 2px; }',
'input' : 'div { padding: 1px 2px 3px 4px; }',
'reversable': true
},
{
'should' : 'Should mirror property value: box-shadow',
'expected' : 'div { box-shadow: -60px -16px teal, -10px 5px 5px red,inset -5em 1em 0 white; }',
'input' : 'div { box-shadow: 60px -16px teal, 10px 5px 5px red,inset 5em 1em 0 white; }',
'reversable': true
},
{
'should' : 'Should mirror property value: text-shadow',
'expected' : 'div { text-shadow: -60px -16px teal, -10px 5px 5px red,inset -5em 1em 0 white; }',
'input' : 'div { text-shadow: 60px -16px teal, 10px 5px 5px red,inset 5em 1em 0 white; }',
'reversable': true
},
'Mirrored Values (N Value Syntax):': [
{
'should': 'Should mirror property value: border-radius (4 values)',
'expected': 'div { border-radius: 40px 10px 10px 40px; }',
'input': 'div { border-radius: 10px 40px 40px 10px; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-radius (3 values)',
'expected': 'div { border-radius: 40px 10px 40px 40px; }',
'input': 'div { border-radius: 10px 40px 40px; }',
'reversable': false
},
{
'should': 'Should mirror property value: border-radius (2 values)',
'expected': 'div { border-radius: 40px 10px; }',
'input': 'div { border-radius: 10px 40px; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-radius (4 values - double)',
'expected': 'div { border-radius: 40px 10px 10px 40px / 4em 1em 1em 4em; }',
'input': 'div { border-radius: 10px 40px 40px 10px / 1em 4em 4em 1em; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-radius (3 values - double)',
'expected': 'div { border-radius: 40px 10px 40px 40px /4em 1em 4em 3em; }',
'input': 'div { border-radius: 10px 40px 40px / 1em 4em 3em; }',
'reversable': false
},
{
'should': 'Should mirror property value: border-radius (2 values- double)',
'expected': 'div { border-radius: 40px 10px / 2em 1em; }',
'input': 'div { border-radius: 10px 40px / 1em 2em; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-width',
'expected': 'div { border-width: 1px 4px 3px 2px; }',
'input': 'div { border-width: 1px 2px 3px 4px; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-width (none length)',
'expected': 'div { border-width: thin medium thick none; }',
'input': 'div { border-width: thin none thick medium; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-style (4 values)',
'expected': 'div { border-style: none dashed dotted solid; }',
'input': 'div { border-style: none solid dotted dashed; }',
'reversable': true
},
{
'should': 'Should mirror property value: border-color (4 values)',
'expected': 'div { border-color: rgba(255, 255, 255, 1) rgb( 0, 0, 0) #000 hsla(0, 100%, 50%, 1); }',
'input': 'div { border-color: rgba(255, 255, 255, 1) hsla(0, 100%, 50%, 1) #000 rgb( 0, 0, 0); }',
'reversable': true
},
{
'should': 'Should not mirror property value: border-color (3 values)',
'expected': 'div { border-color: #000 rgb( 0, 0, 0) hsla(0, 100%, 50%, 1); }',
'input': 'div { border-color: #000 rgb( 0, 0, 0) hsla(0, 100%, 50%, 1); }',
'reversable': false
},
{
'should': 'Should not mirror property value: border-color (2 values)',
'expected': 'div { border-color:rgb( 0, 0, 0) hsla(0, 100%, 50%, 1); }',
'input': 'div { border-color:rgb( 0, 0, 0) hsla(0, 100%, 50%, 1); }',
'reversable': false
},
{
'should': 'Should mirror property value: margin',
'expected': 'div { margin: 1px auto 3px 2px; }',
'input': 'div { margin: 1px 2px 3px auto; }',
'reversable': true
},
{
'should': 'Should mirror property value: padding',
'expected': 'div { padding: 1px 4px 3px 2px; }',
'input': 'div { padding: 1px 2px 3px 4px; }',
'reversable': true
},
{
'should': 'Should mirror property value: box-shadow',
'expected': 'div { box-shadow: -60px -16px teal, -10px 5px 5px red,inset -5em 1em 0 white; }',
'input': 'div { box-shadow: 60px -16px teal, 10px 5px 5px red,inset 5em 1em 0 white; }',
'reversable': true
},
{
'should': 'Should mirror property value: text-shadow',
'expected': 'div { text-shadow: -60px -16px teal, -10px 5px 5px red,inset -5em 1em 0 white; }',
'input': 'div { text-shadow: 60px -16px teal, 10px 5px 5px red,inset 5em 1em 0 white; }',
'reversable': true
},
],
'Transform Origin:': [
'Transform Origin:': [
{
'should': 'Should mirror (x-offset: 0 means 0%)',
'expected': 'div { transform-origin:100%; }',
'input': 'div { transform-origin:0; }',
'reversable': false
},
{
'should': 'Should mirror (x-offset)',
'expected': 'div { transform-origin:90%; }',
'input': 'div { transform-origin:10%; }',
'reversable': true
},
{
'should': 'Should not mirror (x-offset: not percent)',
'expected': 'div { transform-origin:10px; }',
'input': 'div { transform-origin:10px; }',
'reversable': false
},
{
'should': 'Should mirror (offset-keyword)',
'expected': 'div { transform-origin:right; }',
'input': 'div { transform-origin:left; }',
'reversable': true
},
{
'should': 'Should mirror (x-offset y-offset: 0 means 0%)',
'expected': 'div { transform-origin:100% 0; }',
'input': 'div { transform-origin:0 0; }',
'reversable': false
},
{
'should': 'Should mirror (x-offset y-offset)',
'expected': 'div { transform-origin:30% 10%; }',
'input': 'div { transform-origin:70% 10%; }',
'reversable': true
},
{
'should': 'Should mirror (y-offset x-offset-keyword)',
'expected': 'div { transform-origin:70% right; }',
'input': 'div { transform-origin:70% left; }',
'reversable': true
},
{
'should': 'Should mirror (x-offset-keyword y-offset)',
'expected': 'div { transform-origin:right 70%; }',
'input': 'div { transform-origin:left 70%; }',
'reversable': true
},
{
'should': 'Should mirror (y-offset-keyword x-offset)',
'expected': 'div { transform-origin:top 30%; }',
'input': 'div { transform-origin:top 70%; }',
'reversable': true
},
{
'should': 'Should mirror (x-offset-keyword y-offset-keyword)',
'expected': 'div { transform-origin:right top; }',
'input': 'div { transform-origin:left top; }',
'reversable': true
},
{
'should': 'Should mirror (y-offset-keyword x-offset-keyword)',
'expected': 'div { transform-origin:top right; }',
'input': 'div { transform-origin:top left; }',
'reversable': true
},
{
'should': 'Should mirror (x-offset y-offset z-offset)',
'expected': 'div { transform-origin:80% 30% 10%; }',
'input': 'div { transform-origin:20% 30% 10%; }',
'reversable': true
},
{
'should': 'Should mirror (y-offset x-offset-keyword z-offset)',
'expected': 'div { transform-origin:20% right 10%; }',
'input': 'div { transform-origin:20% left 10%; }',
'reversable': true
},
{
'should': 'Should mirror (x-offset-keyword y-offset z-offset)',
'expected': 'div { transform-origin:left 20% 10%; }',
'input': 'div { transform-origin:right 20% 10%; }',
'reversable': true
},
{
'should': 'Should mirror (x-offset-keyword y-offset-keyword z-offset)',
'expected': 'div { transform-origin:left bottom 10%; }',
'input': 'div { transform-origin:right bottom 10%; }',
'reversable': true
},
{
'should': 'Should mirror (y-offset-keyword x-offset-keyword z-offset)',
'expected': 'div { transform-origin:bottom left 10%; }',
'input': 'div { transform-origin:bottom right 10%; }',
'reversable': true
},
],
'Transforms:': [
{
'should': 'Should mirror transform : matrix',
'expected': 'div { transform: matrix(2, 0.1, 2, 2, 2, 2); }',
'input': 'div { transform: matrix(2, -0.1, -2, 2, -2, 2); }',
'reversable': true
},
{
'should': 'Should mirror transform : translate',
'expected': 'div { transform: translate(-100px); }',
'input': 'div { transform: translate(100px); }',
'reversable': true
},
{
'should': 'Should mirror transform : translateX',
'expected': 'div { transform: translateX(-50px); }',
'input': 'div { transform: translateX(50px); }',
'reversable': true
},
{
'should': 'Should mirror transform : translate3d',
'expected': 'div { transform: translate3d(-12px, 50%, 3em); }',
'input': 'div { transform: translate3d(12px, 50%, 3em); }',
'reversable': true
},
{
'should': 'Should mirror transform : rotate',
'expected': 'div { transform: rotate(-20deg); }',
'input': 'div { transform: rotate(20deg); }',
'reversable': true
},
{
'should': 'Should mirror transform : rotate3d',
'expected': 'div { transform: rotate3d(10, -20, 10, -45deg); }',
'input': 'div { transform: rotate3d(10, 20, 10, 45deg); }',
'reversable': true
},
{
'should': 'Should not mirror transform : rotateX',
'expected': 'div { transform: rotateX(45deg); }',
'input': 'div { transform: rotateX(45deg); }',
'reversable': false
},
{
'should': 'Should not mirror transform : rotateY',
'expected': 'div { transform: rotateY(45deg); }',
'input': 'div { transform: rotateY(45deg); }',
'reversable': false
},
{
'should': 'Should mirror transform : rotateZ',
'expected': 'div { transform: rotateZ(-45deg); }',
'input': 'div { transform: rotateZ(45deg); }',
'reversable': true
},
{
'should': 'Should mirror transform : skew',
'expected': 'div { transform: skew(-20rad,-30deg); }',
'input': 'div { transform: skew(20rad,30deg); }',
'reversable': true
},
{
'should': 'Should mirror transform : skewX',
'expected': 'div { transform: skewX(-20rad); }',
'input': 'div { transform: skewX(20rad); }',
'reversable': true
},
{
'should': 'Should mirror transform : skewY',
'expected': 'div { transform: skewY(-10grad); }',
'input': 'div { transform: skewY(10grad); }',
'reversable': true
},
],
'RTLCSS (Options):': [
{
'should' : 'Should mirror (x-offset: 0 means 0%)',
'expected' : 'div { transform-origin:100%; }',
'input' : 'div { transform-origin:0; }',
'reversable': false
},
{
'should' : 'Should mirror (x-offset)',
'expected' : 'div { transform-origin:90%; }',
'input' : 'div { transform-origin:10%; }',
'should': 'Should not rename selectors having directional decl. (default)',
'expected': '.right .rtl .east .bright .ultra .least { display:block; right:0; }',
'input': '.right .rtl .east .bright .ultra .least { display:block; left:0; }',
'reversable': true
},
{
'should' : 'Should not mirror (x-offset: not percent)',
'expected' : 'div { transform-origin:10px; }',
'input' : 'div { transform-origin:10px; }',
'reversable': false
},
{
'should' : 'Should mirror (offset-keyword)',
'expected' : 'div { transform-origin:right; }',
'input' : 'div { transform-origin:left; }',
'reversable': true
},
{
'should' : 'Should mirror (x-offset y-offset: 0 means 0%)',
'expected' : 'div { transform-origin:100% 0; }',
'input' : 'div { transform-origin:0 0; }',
'reversable': false
},
{
'should' : 'Should mirror (x-offset y-offset)',
'expected' : 'div { transform-origin:30% 10%; }',
'input' : 'div { transform-origin:70% 10%; }',
'should': 'Should auto rename selectors having no directional decl. (default)',
'expected': '.left .ltr .west .bright .ultra .least { display:block; }',
'input': '.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': true
},
{
'should' : 'Should mirror (y-offset x-offset-keyword)',
'expected' : 'div { transform-origin:70% right; }',
'input' : 'div { transform-origin:70% left; }',
'reversable': true
},
{
'should' : 'Should mirror (x-offset-keyword y-offset)',
'expected' : 'div { transform-origin:right 70%; }',
'input' : 'div { transform-origin:left 70%; }',
'reversable': true
},
{
'should' : 'Should mirror (y-offset-keyword x-offset)',
'expected' : 'div { transform-origin:top 30%; }',
'input' : 'div { transform-origin:top 70%; }',
'reversable': true
},
{
'should' : 'Should mirror (x-offset-keyword y-offset-keyword)',
'expected' : 'div { transform-origin:right top; }',
'input' : 'div { transform-origin:left top; }',
'reversable': true
},
{
'should' : 'Should mirror (y-offset-keyword x-offset-keyword)',
'expected' : 'div { transform-origin:top right; }',
'input' : 'div { transform-origin:top left; }',
'reversable': true
},
{
'should' : 'Should mirror (x-offset y-offset z-offset)',
'expected' : 'div { transform-origin:80% 30% 10%; }',
'input' : 'div { transform-origin:20% 30% 10%; }',
'reversable': true
},
{
'should' : 'Should mirror (y-offset x-offset-keyword z-offset)',
'expected' : 'div { transform-origin:20% right 10%; }',
'input' : 'div { transform-origin:20% left 10%; }',
'reversable': true
},
{
'should' : 'Should mirror (x-offset-keyword y-offset z-offset)',
'expected' : 'div { transform-origin:left 20% 10%; }',
'input' : 'div { transform-origin:right 20% 10%; }',
'reversable': true
},
{
'should' : 'Should mirror (x-offset-keyword y-offset-keyword z-offset)',
'expected' : 'div { transform-origin:left bottom 10%; }',
'input' : 'div { transform-origin:right bottom 10%; }',
'reversable': true
},
{
'should' : 'Should mirror (y-offset-keyword x-offset-keyword z-offset)',
'expected' : 'div { transform-origin:bottom left 10%; }',
'input' : 'div { transform-origin:bottom right 10%; }',
'reversable': true
},
],
'Transforms:': [
{
'should' : 'Should mirror transform : matrix',
'expected' : 'div { transform: matrix(2, 0.1, 2, 2, 2, 2); }',
'input' : 'div { transform: matrix(2, -0.1, -2, 2, -2, 2); }',
'reversable': true
},
{
'should' : 'Should mirror transform : translate',
'expected' : 'div { transform: translate(-100px); }',
'input' : 'div { transform: translate(100px); }',
'reversable': true
},
{
'should' : 'Should mirror transform : translateX',
'expected' : 'div { transform: translateX(-50px); }',
'input' : 'div { transform: translateX(50px); }',
'reversable': true
},
{
'should' : 'Should mirror transform : translate3d',
'expected' : 'div { transform: translate3d(-12px, 50%, 3em); }',
'input' : 'div { transform: translate3d(12px, 50%, 3em); }',
'reversable': true
},
{
'should' : 'Should mirror transform : rotate',
'expected' : 'div { transform: rotate(-20deg); }',
'input' : 'div { transform: rotate(20deg); }',
'reversable': true
},
{
'should' : 'Should mirror transform : rotate3d',
'expected' : 'div { transform: rotate3d(10, -20, 10, -45deg); }',
'input' : 'div { transform: rotate3d(10, 20, 10, 45deg); }',
'reversable': true
},
{
'should' : 'Should not mirror transform : rotateX',
'expected' : 'div { transform: rotateX(45deg); }',
'input' : 'div { transform: rotateX(45deg); }',
'reversable': false
},
{
'should' : 'Should not mirror transform : rotateY',
'expected' : 'div { transform: rotateY(45deg); }',
'input' : 'div { transform: rotateY(45deg); }',
'reversable': false
},
{
'should' : 'Should mirror transform : rotateZ',
'expected' : 'div { transform: rotateZ(-45deg); }',
'input' : 'div { transform: rotateZ(45deg); }',
'reversable': true
},
{
'should' : 'Should mirror transform : skew',
'expected' : 'div { transform: skew(-20rad,-30deg); }',
'input' : 'div { transform: skew(20rad,30deg); }',
'reversable': true
},
{
'should' : 'Should mirror transform : skewX',
'expected' : 'div { transform: skewX(-20rad); }',
'input' : 'div { transform: skewX(20rad); }',
'reversable': true
},
{
'should' : 'Should mirror transform : skewY',
'expected' : 'div { transform: skewY(-10grad); }',
'input' : 'div { transform: skewY(10grad); }',
'reversable': true
},
],
'RTLCSS (Options):': [
{
'should' : 'Should not rename selectors having directional decl. (default)',
'expected' : '.right .rtl .east .bright .ultra .least { display:block; right:0; }',
'input' : '.right .rtl .east .bright .ultra .least { display:block; left:0; }',
'reversable': true
},
{
'should' : 'Should auto rename selectors having no directional decl. (default)',
'expected' : '.left .ltr .west .bright .ultra .least { display:block; }',
'input' : '.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': true
},
{
'should' : 'Should auto rename selectors having no directional decl. (greedy)',
'expected' : '.left .ltr .west .bleft .urtla .lwest { display:block; }',
'input' : '.right .rtl .east .bright .ultra .least { display:block; }',
'should': 'Should auto rename selectors having no directional decl. (greedy)',
'expected': '.left .ltr .west .bleft .urtla .lwest { display:block; }',
'input': '.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': true,
'options' : {'greedy':true}
'options': { 'greedy': true }
},
{
'should' : 'Should not auto rename selectors having no directional decl. (autoRename:false)',
'expected' : '.right .rtl .east .bright .ultra .least { display:block; }',
'input' : '.right .rtl .east .bright .ultra .least { display:block; }',
'should': 'Should not auto rename selectors having no directional decl. (autoRename:false)',
'expected': '.right .rtl .east .bright .ultra .least { display:block; }',
'input': '.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': true,
'options' : {'autoRename': false }
'options': { 'autoRename': false }
},
{
'should' : 'Should not auto rename selectors having no directional decl. (autoRename:false,greedy)',
'expected' : '.right .rtl .east .bright .ultra .least { display:block; }',
'input' : '.right .rtl .east .bright .ultra .least { display:block; }',
'should': 'Should not auto rename selectors having no directional decl. (autoRename:false,greedy)',
'expected': '.right .rtl .east .bright .ultra .least { display:block; }',
'input': '.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': true,
'options' : {'autoRename': false, 'greedy': true }
'options': { 'autoRename': false, 'greedy': true }
},
{
'should' : 'Should not preserve processing directive. (default)',
'expected' : 'div { left:0; }',
'input' : '/*rtl:ignore*/div { left:0; }',
'should': 'Should not preserve processing directive. (default)',
'expected': 'div { left:0; }',
'input': '/*rtl:ignore*/div { left:0; }',
'reversable': false,
},
{
'should' : 'Should preserve processing directive. (preserveDirectives:true)',
'expected' : '/*rtl:ignore*/div { left:0; }',
'input' : '/*rtl:ignore*/div { left:0; }',
'should': 'Should preserve processing directive. (preserveDirectives:true)',
'expected': '/*rtl:ignore*/div { left:0; }',
'input': '/*rtl:ignore*/div { left:0; }',
'reversable': false,
'options' : {'preserveDirectives':true}
'options': { 'preserveDirectives': true }
},
{
'should' : 'Should swap left with right in url (defult)',
'expected' : 'div { background-image: url(rtl/west/right.png); right:0; }',
'input' : 'div { background-image: url(ltr/east/left.png); left:0; }',
'should': 'Should swap left with right in url (defult)',
'expected': 'div { background-image: url(rtl/west/right.png); right:0; }',
'input': 'div { background-image: url(ltr/east/left.png); left:0; }',
'reversable': true
},
{
'should' : 'Should not swap left with right in url (swapLeftRightInUrl:false)',
'expected' : 'div { background-image: url(rtl/west/left.png); right:0; }',
'input' : 'div { background-image: url(ltr/east/left.png); left:0; }',
'should': 'Should not swap left with right in url (swapLeftRightInUrl:false)',
'expected': 'div { background-image: url(rtl/west/left.png); right:0; }',
'input': 'div { background-image: url(ltr/east/left.png); left:0; }',
'reversable': true,
'options' : {'swapLeftRightInUrl':false}
'options': { 'swapLeftRightInUrl': false }
},
{
'should' : 'Should swap ltr with rtl in url (defult)',
'expected' : 'div { background-image: url(rtl/west/right.png); right:0; }',
'input' : 'div { background-image: url(ltr/east/left.png); left:0; }',
'should': 'Should swap ltr with rtl in url (defult)',
'expected': 'div { background-image: url(rtl/west/right.png); right:0; }',
'input': 'div { background-image: url(ltr/east/left.png); left:0; }',
'reversable': true
},
{
'should' : 'Should not swap ltr with rtl in url (swapLtrRtlInUrl:false)',
'expected' : 'div { background-image: url(ltr/west/right.png); right:0; }',
'input' : 'div { background-image: url(ltr/east/left.png); left:0; }',
'should': 'Should not swap ltr with rtl in url (swapLtrRtlInUrl:false)',
'expected': 'div { background-image: url(ltr/west/right.png); right:0; }',
'input': 'div { background-image: url(ltr/east/left.png); left:0; }',
'reversable': false,
'options' : {'swapLtrRtlInUrl':false}
'options': { 'swapLtrRtlInUrl': false }
},
{
'should' : 'Should swap east with west in url (defult)',
'expected' : 'div { background-image: url(rtl/west/right.png); right:0; }',
'input' : 'div { background-image: url(ltr/east/left.png); left:0; }',
'should': 'Should swap east with west in url (defult)',
'expected': 'div { background-image: url(rtl/west/right.png); right:0; }',
'input': 'div { background-image: url(ltr/east/left.png); left:0; }',
'reversable': true
},
{
'should' : 'Should not swap east with west in url (swapWestEastInUrl:false)',
'expected' : 'div { background-image: url(rtl/east/right.png); right:0; }',
'input' : 'div { background-image: url(ltr/east/left.png); left:0; }',
'should': 'Should not swap east with west in url (swapWestEastInUrl:false)',
'expected': 'div { background-image: url(rtl/east/right.png); right:0; }',
'input': 'div { background-image: url(ltr/east/left.png); left:0; }',
'reversable': false,
'options' : {'swapWestEastInUrl':false}
'options': { 'swapWestEastInUrl': false }
},
{
'should' : 'Should swap left with right in @import url (swapLeftRightInUrl:true)',
'expected' : 'div{display:none;} @import url("right.css");',
'input' : 'div{display:none;} @import url("left.css");',
'reversable': true,
'options' : {'swapLeftRightInUrl':true}
},
'should': 'Should swap left with right in @import url (swapLeftRightInUrl:true)',
'expected': 'div{display:none;} @import url("right.css");',
'input': 'div{display:none;} @import url("left.css");',
'reversable': true,
'options': { 'swapLeftRightInUrl': true }
},
{
'should' : 'Should not swap bright with bleft in @import url (swapLeftRightInUrl:true,greedy:false)',
'expected' : 'div{display:none;} @import url("bright.css");',
'input' : 'div{display:none;} @import url("bright.css");',
'reversable': true,
'options' : {'swapLeftRightInUrl':true, 'greedy':false}
},
'should': 'Should not swap bright with bleft in @import url (swapLeftRightInUrl:true,greedy:false)',
'expected': 'div{display:none;} @import url("bright.css");',
'input': 'div{display:none;} @import url("bright.css");',
'reversable': true,
'options': { 'swapLeftRightInUrl': true, 'greedy': false }
},
{
'should' : 'Should swap bright with bleft in @import url (swapLeftRightInUrl:true,greedy:true)',
'expected' : 'div{display:none;} @import url("bleft.css");',
'input' : 'div{display:none;} @import url("bright.css");',
'reversable': true,
'options' : {'swapLeftRightInUrl':true, 'greedy':true}
},
'should': 'Should swap bright with bleft in @import url (swapLeftRightInUrl:true,greedy:true)',
'expected': 'div{display:none;} @import url("bleft.css");',
'input': 'div{display:none;} @import url("bright.css");',
'reversable': true,
'options': { 'swapLeftRightInUrl': true, 'greedy': true }
},
{
'should' : 'Should swap ltr with rtl in @import url (swapLtrRtlInUrl:true)',
'expected' : 'div{display:none;} @import url("rtl.css");',
'input' : 'div{display:none;} @import url("ltr.css");',
'reversable': true,
'options' : {'swapLtrRtlInUrl':true}
},
'should': 'Should swap ltr with rtl in @import url (swapLtrRtlInUrl:true)',
'expected': 'div{display:none;} @import url("rtl.css");',
'input': 'div{display:none;} @import url("ltr.css");',
'reversable': true,
'options': { 'swapLtrRtlInUrl': true }
},
{
'should' : 'Should not swap ultra with urtla in @import url (swapLtrRtlInUrl:true,greedy:false)',
'expected' : 'div{display:none;} @import url("ultra.css");',
'input' : 'div{display:none;} @import url("ultra.css");',
'reversable': true,
'options' : {'swapLtrRtlInUrl':true, 'greedy':false}
},
'should': 'Should not swap ultra with urtla in @import url (swapLtrRtlInUrl:true,greedy:false)',
'expected': 'div{display:none;} @import url("ultra.css");',
'input': 'div{display:none;} @import url("ultra.css");',
'reversable': true,
'options': { 'swapLtrRtlInUrl': true, 'greedy': false }
},
{
'should' : 'Should swap ultra with urtla in @import url (swapLtrRtlInUrl:true,greedy:true)',
'expected' : 'div{display:none;} @import url("urtla.css");',
'input' : 'div{display:none;} @import url("ultra.css");',
'reversable': true,
'options' : {'swapLtrRtlInUrl':true, 'greedy':true}
},
'should': 'Should swap ultra with urtla in @import url (swapLtrRtlInUrl:true,greedy:true)',
'expected': 'div{display:none;} @import url("urtla.css");',
'input': 'div{display:none;} @import url("ultra.css");',
'reversable': true,
'options': { 'swapLtrRtlInUrl': true, 'greedy': true }
},
{
'should' : 'Should swap west with east in @import url (swapWestEastInUrl:true)',
'expected' : 'div{display:none;} @import url("east.css");',
'input' : 'div{display:none;} @import url("west.css");',
'reversable': true,
'options' : {'swapWestEastInUrl':true}
},
'should': 'Should swap west with east in @import url (swapWestEastInUrl:true)',
'expected': 'div{display:none;} @import url("east.css");',
'input': 'div{display:none;} @import url("west.css");',
'reversable': true,
'options': { 'swapWestEastInUrl': true }
},
{
'should' : 'Should not swap western with eastern in @import url (swapWestEastInUrl:true,greedy:false)',
'expected' : 'div{display:none;} @import url("western.css");',
'input' : 'div{display:none;} @import url("western.css");',
'reversable': true,
'options' : {'swapWestEastInUrl':true, 'greedy':false}
},
'should': 'Should not swap western with eastern in @import url (swapWestEastInUrl:true,greedy:false)',
'expected': 'div{display:none;} @import url("western.css");',
'input': 'div{display:none;} @import url("western.css");',
'reversable': true,
'options': { 'swapWestEastInUrl': true, 'greedy': false }
},
{
'should' : 'Should swap western with eastern in @import url (swapWestEastInUrl:true,greedy:true)',
'expected' : 'div{display:none;} @import url("eastern.css");',
'input' : 'div{display:none;} @import url("western.css");',
'reversable': true,
'options' : {'swapWestEastInUrl':true, 'greedy':true}
},
'should': 'Should swap western with eastern in @import url (swapWestEastInUrl:true,greedy:true)',
'expected': 'div{display:none;} @import url("eastern.css");',
'input': 'div{display:none;} @import url("western.css");',
'reversable': true,
'options': { 'swapWestEastInUrl': true, 'greedy': true }
},
{
'should' : 'Should minify (minify:true)',
'expected' : 'div{font-family:"Droid Arabic Kufi";padding:10px 5px 5px 10px;color:red;}.div2{display:none;}',
'input' : '\n/*comment*/\ndiv\n/*comment*/\n {\n/*comment*/\n font-family:\n/*comment*/\n "Droid Arabic Kufi";\n/*comment*/\n padding:10px 10px 5px 5px;\n/*comment*/\n color:red; \n/*comment*/\n } \n/*comment*/\n .div2{ /*comment*/ \n display:none; /*comment*/ \n /*comment*/}',
'should': 'Should minify (minify:true)',
'expected': 'div{font-family:"Droid Arabic Kufi";padding:10px 5px 5px 10px;color:red;}.div2{display:none;}',
'input': '\n/*comment*/\ndiv\n/*comment*/\n {\n/*comment*/\n font-family:\n/*comment*/\n "Droid Arabic Kufi";\n/*comment*/\n padding:10px 10px 5px 5px;\n/*comment*/\n color:red; \n/*comment*/\n } \n/*comment*/\n .div2{ /*comment*/ \n display:none; /*comment*/ \n /*comment*/}',
'reversable': false,
'options' : {'minify':true}
'options': { 'minify': true }
}

@@ -694,8 +694,15 @@ ],

{
'should' : 'Should auto rename selectors having no directional decl. unless forced to ignore. (default)',
'expected' : ' .right .rtl .east .bright .ultra .least { display:block; }',
'input' : '/*rtl:ignore*/ .right .rtl .east .bright .ultra .least { display:block; }',
'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (default)',
'expected': ' .right .rtl .east .bright .ultra .least { display:block; }',
'input': '/*rtl:ignore*/ .right .rtl .east .bright .ultra .least { display:block; }',
'reversable': false,
},
{
'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (preserveDirectives)',
'expected': '/*rtl:ignore*/ .right .rtl .east .bright .ultra .least { display:block; }',
'input': '/*rtl:ignore*/ .right .rtl .east .bright .ultra .least { display:block; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (default, !important comment)',

@@ -707,9 +714,16 @@ 'expected': ' .right .rtl .east .bright .ultra .least { display:block; }',

{
'should' : 'Should auto rename selectors having no directional decl. unless forced to ignore. (greedy)',
'expected' : ' .right .rtl .east .bright .ultra .least { display:block; }',
'input' : '/*rtl:ignore*/ .right .rtl .east .bright .ultra .least { display:block; }',
'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (preserveDirectives, !important comment)',
'expected': '/*!rtl:ignore*/ .right .rtl .east .bright .ultra .least { display:block; }',
'input': '/*!rtl:ignore*/ .right .rtl .east .bright .ultra .least { display:block; }',
'reversable': false,
'options' : {'greedy':true}
'options': { 'preserveDirectives': true }
},
{
'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (greedy)',
'expected': ' .right .rtl .east .bright .ultra .least { display:block; }',
'input': '/*rtl:ignore*/ .right .rtl .east .bright .ultra .least { display:block; }',
'reversable': false,
'options': { 'greedy': true }
},
{
'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (greedy, !important comment)',

@@ -722,9 +736,16 @@ 'expected': ' .right .rtl .east .bright .ultra .least { display:block; }',

{
'should' : 'Should rename selectors when forced. (autoRename:false)',
'expected' : '.left .ltr .west .bright .ultra .least { display:block; }',
'input' : '/*rtl:rename*/.right .rtl .east .bright .ultra .least { display:block; }',
'should': 'Should rename selectors when forced. (autoRename:false)',
'expected': '.left .ltr .west .bright .ultra .least { display:block; }',
'input': '/*rtl:rename*/.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': false,
'options' : {'autoRename': false }
'options': { 'autoRename': false }
},
{
'should': 'Should rename selectors when forced. (autoRename:false, preserveDirectives)',
'expected': '/*rtl:rename*/.left .ltr .west .bright .ultra .least { display:block; }',
'input': '/*rtl:rename*/.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': false,
'options': { 'autoRename': false, 'preserveDirectives': true }
},
{
'should': 'Should rename selectors when forced. (autoRename:false, !important comment)',

@@ -737,9 +758,16 @@ 'expected': '.left .ltr .west .bright .ultra .least { display:block; }',

{
'should' : 'Should rename selectors when forced. (autoRename:false,greedy)',
'expected' : '.left .ltr .west .bleft .urtla .lwest { display:block; }',
'input' : '/*rtl:rename*/.right .rtl .east .bright .ultra .least { display:block; }',
'should': 'Should rename selectors when forced. (autoRename:false, preserveDirectives, !important comment)',
'expected': '/*!rtl:rename*/.left .ltr .west .bright .ultra .least { display:block; }',
'input': '/*!rtl:rename*/.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': false,
'options' : {'autoRename': false, 'greedy': true }
'options': { 'autoRename': false, 'preserveDirectives': true }
},
{
'should': 'Should rename selectors when forced. (autoRename:false,greedy)',
'expected': '.left .ltr .west .bleft .urtla .lwest { display:block; }',
'input': '/*rtl:rename*/.right .rtl .east .bright .ultra .least { display:block; }',
'reversable': false,
'options': { 'autoRename': false, 'greedy': true }
},
{
'should': 'Should rename selectors when forced. (autoRename:false,greedy, !important comment)',

@@ -752,8 +780,15 @@ 'expected': '.left .ltr .west .bleft .urtla .lwest { display:block; }',

{
'should' : 'Should prepend value.',
'expected' : 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma; }',
'input' : 'div { font-family: "Droid Sans", Tahoma/*rtl:prepend:"Droid Arabic Kufi", */; }',
'should': 'Should prepend value. (default)',
'expected': 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:prepend:"Droid Arabic Kufi", */; }',
'reversable': false,
},
{
'should': 'Should prepend value. (preserveDirectives)',
'expected': 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma/*rtl:prepend:"Droid Arabic Kufi", */; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:prepend:"Droid Arabic Kufi", */; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should prepend value (!important comment)',

@@ -765,8 +800,22 @@ 'expected': 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma; }',

{
'should' : 'Should replace value.',
'expected' : 'div { font-family: "Droid Arabic Kufi"; }',
'input' : 'div { font-family: "Droid Sans", Tahoma/*rtl:"Droid Arabic Kufi"*/; }',
'should': 'Should prepend value (preserveDirectives, !important comment)',
'expected': 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma/*!rtl:prepend:"Droid Arabic Kufi", */; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:prepend:"Droid Arabic Kufi", */; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should replace value.',
'expected': 'div { font-family: "Droid Arabic Kufi"; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:"Droid Arabic Kufi"*/; }',
'reversable': false,
},
{
'should': 'Should replace value.(preserveDirectives)',
'expected': 'div { font-family: "Droid Arabic Kufi"/*rtl:"Droid Arabic Kufi"*/; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:"Droid Arabic Kufi"*/; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should replace value. (!important comment)',

@@ -778,8 +827,22 @@ 'expected': 'div { font-family: "Droid Arabic Kufi"; }',

{
'should' : 'Should append value.',
'expected' : 'div { font-family: "Droid Sans", Tahoma, "Droid Arabic Kufi"; }',
'input' : 'div { font-family: "Droid Sans", Tahoma/*rtl:append:, "Droid Arabic Kufi"*/; }',
'should': 'Should replace value. (preserveDirectives, !important comment)',
'expected': 'div { font-family: "Droid Arabic Kufi"/*!rtl:"Droid Arabic Kufi"*/; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:"Droid Arabic Kufi"*/; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should append value. (default)',
'expected': 'div { font-family: "Droid Sans", Tahoma, "Droid Arabic Kufi"; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:append:, "Droid Arabic Kufi"*/; }',
'reversable': false,
},
{
'should': 'Should append value. (preserveDirectives)',
'expected': 'div { font-family: "Droid Sans", Tahoma/*rtl:append:, "Droid Arabic Kufi"*/, "Droid Arabic Kufi"; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:append:, "Droid Arabic Kufi"*/; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should append value. (!important comment)',

@@ -791,8 +854,22 @@ 'expected': 'div { font-family: "Droid Sans", Tahoma, "Droid Arabic Kufi"; }',

{
'should' : 'Should insert value.',
'expected' : 'div { font-family: "Droid Sans", "Droid Arabic Kufi", Tahoma; }',
'input' : 'div { font-family: "Droid Sans"/*rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
'should': 'Should append value. (preserveDirectives, !important comment)',
'expected': 'div { font-family: "Droid Sans", Tahoma/*!rtl:append:, "Droid Arabic Kufi"*/, "Droid Arabic Kufi"; }',
'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:append:, "Droid Arabic Kufi"*/; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should insert value. (default)',
'expected': 'div { font-family: "Droid Sans", "Droid Arabic Kufi", Tahoma; }',
'input': 'div { font-family: "Droid Sans"/*rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
'reversable': false,
},
{
'should': 'Should insert value. (preserveDirectives)',
'expected': 'div { font-family: "Droid Sans", "Droid Arabic Kufi"/*rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
'input': 'div { font-family: "Droid Sans"/*rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should insert value. (!important comment)',

@@ -804,10 +881,24 @@ 'expected': 'div { font-family: "Droid Sans", "Droid Arabic Kufi", Tahoma; }',

{
'should' : 'Should ignore flipping (rule level)',
'expected' : 'div { left:10px; text-align:right;}',
'input' : '/*rtl:ignore*/div { left:10px; text-align:right;}',
'should': 'Should insert value. (preserveDirectives, !important comment)',
'expected': 'div { font-family: "Droid Sans", "Droid Arabic Kufi"/*!rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
'input': 'div { font-family: "Droid Sans"/*!rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should ignore flipping (rule level, !important comment)',
'should': 'Should ignore flipping - rule level (default)',
'expected': 'div { left:10px; text-align:right;}',
'input': '/*rtl:ignore*/div { left:10px; text-align:right;}',
'reversable': false,
},
{
'should': 'Should ignore flipping - rule level (preserveDirectives)',
'expected': '/*rtl:ignore*/div { left:10px; text-align:right;}',
'input': '/*rtl:ignore*/div { left:10px; text-align:right;}',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should ignore flipping - rule level (default, !important comment)',
'expected': 'div { left:10px; text-align:right;}',
'input': '/*!rtl:ignore*/div { left:10px; text-align:right;}',

@@ -817,16 +908,111 @@ 'reversable': false,

{
'should' : 'Should ignore flipping (decl. level)',
'expected' : 'div { left:10px;text-align:left;}',
'input' : 'div { left:10px/*rtl:ignore*/;text-align:right;}',
'should': 'Should ignore flipping - rule level (preserveDirectives , !important comment)',
'expected': '/*!rtl:ignore*/div { left:10px; text-align:right;}',
'input': '/*!rtl:ignore*/div { left:10px; text-align:right;}',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should ignore flipping (decl. level, !important comment)',
'should': 'Should ignore flipping - decl. level (default)',
'expected': 'div { left:10px;text-align:left;}',
'input': 'div { left:10px/*rtl:ignore*/;text-align:right;}',
'reversable': false,
},
{
'should': 'Should ignore flipping - decl. level (preserveDirectives)',
'expected': 'div { left:10px/*rtl:ignore*/;text-align:left;}',
'input': 'div { left:10px/*rtl:ignore*/;text-align:right;}',
'reversable': false,
'options': { 'preserveDirectives': true }
},
{
'should': 'Should ignore flipping - decl. level (default, !important comment)',
'expected': 'div { left:10px;text-align:left;}',
'input': 'div { left:10px/*!rtl:ignore*/;text-align:right;}',
'reversable': false,
},
{
'should': 'Should ignore flipping - decl. level (preserveDirectives, !important comment)',
'expected': 'div { left:10px/*!rtl:ignore*/;text-align:left;}',
'input': 'div { left:10px/*!rtl:ignore*/;text-align:right;}',
'options': { 'preserveDirectives': true }
},
],
'RTLCSS (String Map):': [
{
'should': 'Should rename "left", "Left", "LEFT" (default). ',
'expected': 'div.right, div.Right, div.RIGHT, div.respectLeft { width:10px;}',
'input': 'div.left, div.Left, div.LEFT, div.respectLeft { width:10px;}',
'reversable':true
},
{
'should': 'Should rename "left", "Left", "LEFT" (greedy). ',
'expected': 'div.right, div.Right, div.RIGHT, div.respectRight { width:10px;}',
'input': 'div.left, div.Left, div.LEFT, div.respectLeft { width:10px;}',
'reversable': true,
'options': {
'greedy':true
}
},
{
'should': 'Should rename "ltr", "Ltr", "LTR" (default). ',
'expected': 'div.rtl, div.Rtl, div.RTL, div.Ultra { width:10px;}',
'input': 'div.ltr, div.Ltr, div.LTR, div.Ultra { width:10px;}',
'reversable': true
},
{
'should': 'Should rename "ltr", "Ltr", "LTR" (greedy). ',
'expected': 'div.rtl, div.Rtl, div.RTL, div.Urtla { width:10px;}',
'input': 'div.ltr, div.Ltr, div.LTR, div.Ultra { width:10px;}',
'reversable': true,
'options': {
'greedy': true
}
},
{
'should': 'Should rename "west", "West", "WEST" (default). ',
'expected': 'div.east, div.East, div.EAST, div.Western { width:10px;}',
'input': 'div.west, div.West, div.WEST, div.Western { width:10px;}',
'reversable': true
},
{
'should': 'Should rename "west", "West", "WEST" (greedy). ',
'expected': 'div.east, div.East, div.EAST, div.Eastern { width:10px;}',
'input': 'div.west, div.West, div.WEST, div.Western { width:10px;}',
'reversable': true,
'options': {
'greedy': true
}
},
{
'should': 'Should rename "prev"/"next"',
'expected': 'div.next, div.Right { width:10px;}',
'input': 'div.prev, div.Left { width:10px;}',
'reversable':true,
'options': { 'stringMap': [{ "search": "prev", "replace": "next", 'options': { scope: 'selector' } }] }
},
{
'should': 'Should swap "prev"/"next" in Url',
'expected': 'div { background-image: url(/content/pix/next.png);}',
'input': 'div { background-image: url(/content/pix/prev.png);}',
'reversable': true,
'options': { 'stringMap': [{ "search": "prev", "replace": "next", 'options': { scope: 'url' } }] }
},
{
'should': 'Should swap "prev"/"next" in Url and Rename in selector',
'expected': 'div.next { display:block }; div.prev { background-image: url(/content/pix/prev.png);}',
'input': 'div.prev { display:block }; div.prev { background-image: url(/content/pix/next.png);}',
'reversable': true,
'options': { 'stringMap': [{ "search": "prev", "replace": "next", 'options': { scope: '*' } }] }
},
{
'should': 'Should rename "previous" to "nextious" (autoRename:true, greedy: true)',
'expected': 'div.nextious{ width:10px;}',
'input': 'div.previous{ width:10px;}',
'reversable':true,
'options': { 'stringMap': [{ "name": "prev-next", "search": "prev", "replace": "next", options: { greedy: true } }] }
}
]
};
(function Run() {

@@ -836,15 +1022,15 @@ for (key in tests) {

describe(key, function () {
for(var i=0;i<group.length;i++){
var item = group[i];
for (var i = 0; i < group.length; i++) {
var item = group[i];
(function (test) {
it(test.should, function () {
assert.equal(rtlcss.process(test.input,test.options), test.expected);
assert.equal(rtlcss.process(test.input, test.options), test.expected);
});
})(item);
if(item.reversable)
(function (test) {
it(test.should + " <REVERESE>", function () {
assert.equal(rtlcss.process(test.expected,test.options), test.input);
});
})(item);
if (item.reversable)
(function (test) {
it(test.should + " <REVERESE>", function () {
assert.equal(rtlcss.process(test.expected, test.options), test.input);
});
})(item);
};

@@ -851,0 +1037,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc