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 2.4.0 to 2.4.1

3

CHANGELOG.md

@@ -0,1 +1,4 @@

## 2.4.1 - 28 Nov. 2019
* Ignore white spaces before directives prefix.
## 2.4.0 - 20 Jun. 2018

@@ -2,0 +5,0 @@ * New Option:

6

lib/directive-parser.js
module.exports = function (comment) {
var pos = 0
var value = comment.text
var prefix = value.charAt(0) === '!' ? '!rtl:' : 'rtl:'
var match = value.match(/^\s*!?\s*rtl:/)
var meta
if (value.indexOf(prefix) === 0) {
if (match) {
meta = {

@@ -17,3 +17,3 @@ 'source': comment,

}
value = value.slice(prefix.length)
value = value.slice(match[0].length)
pos = value.indexOf(':')

@@ -20,0 +20,0 @@

@@ -22,3 +22,3 @@ 'use strict'

var prevent = true
if (node.type === 'comment' && (node.text === '!rtl:end:ignore' || node.text === 'rtl:end:ignore')) {
if (node.type === 'comment' && node.text.match(/^\s*!?\s*rtl:end:ignore/)) {
prevent = false

@@ -407,8 +407,9 @@ }

'cache': null,
'flip': function (value, context, isPosition) {
'flip': function (value, context) {
var state = util.saveTokens(value, true)
var parts = state.value.match(this.cache.match)
if (parts && parts.length > 0) {
var keywords = (state.value.match(this.cache.position) || '').length
if (isPosition && (/* edge offsets */ parts.length >= 3 || /* keywords only */ keywords === 2)) {
if (/* edge offsets */ parts.length >= 3 || /* keywords only */ keywords === 2) {
state.value = util.swapLeftRight(state.value)

@@ -462,5 +463,4 @@ } else {

if (lprop !== 'background-image') {
var isPosition = lprop === 'background-position'
for (var x = 0; x < parts.length; x++) {
parts[x] = this.flip(parts[x], context, isPosition)
parts[x] = this.flip(parts[x], context)
}

@@ -467,0 +467,0 @@ }

@@ -17,3 +17,3 @@ 'use strict'

var REGEX_COMMENT = /\/\*[^]*?\*\//igm // none-greedy
var REGEX_DIRECTIVE = /\/\*(?:!)?rtl:[^]*?\*\//img
var REGEX_DIRECTIVE = /\/\*\s*(?:!)?\s*rtl:[^]*?\*\//img
var REGEX_ESCAPE = /[.*+?^${}()|[\]\\]/g

@@ -209,3 +209,3 @@ var REGEX_FUNCTION = /\([^\(\)]+\)/i

// /(?:\/\*(?:!)?rtl:ignore(?::)?)([^]*?)(?:\*\/)/img
this.regexCache[name] = this.regexCache[name] || new RegExp('(?:\\/\\*(?:!)?rtl:' + (name ? escapeRegExp(name) + '(?::)?' : '') + ')([^]*?)(?:\\*\\/)', 'img')
this.regexCache[name] = this.regexCache[name] || new RegExp('(?:\\/\\*\\s*(?:!)?\\s*rtl:' + (name ? escapeRegExp(name) + '(?::)?' : '') + ')([^]*?)(?:\\*\\/)', 'img')
return this.regexCache[name]

@@ -212,0 +212,0 @@ },

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

@@ -29,6 +29,6 @@ "homepage": "http://rtlcss.com/",

"dependencies": {
"chalk": "^2.3.0",
"chalk": "^2.4.2",
"findup": "^0.1.5",
"mkdirp": "^0.5.1",
"postcss": "^6.0.14",
"postcss": "^6.0.23",
"strip-json-comments": "^2.0.0"

@@ -35,0 +35,0 @@ },

@@ -27,2 +27,8 @@ module.exports = [

{
'should': 'Should mirror keyword horizontal position (with value)',
'expected': '.banner { background: #00D url(topbanner.png) no-repeat top 50% left 16px; }',
'input': '.banner { background: #00D url(topbanner.png) no-repeat top 50% right 16px; }',
'reversable': true
},
{
'should': 'Should not process string map in url (default)',

@@ -29,0 +35,0 @@ 'expected': '.banner { background: 10px top url(ltr-top-right-banner.png) #00D repeat-y fixed; }',

@@ -407,3 +407,27 @@ module.exports = [

'reversable': false
},
{
'should': 'Should ignore white spaces before value directive prefix',
'expected': ' div { direction:ltr; text-align:right;}',
'input': ' div { direction:ltr/* rtl:ignore*/; text-align:left;}',
'reversable': false
},
{
'should': 'Should ignore white spaces before value directive perfix (!important comment)',
'expected': ' div { direction:ltr; text-align:right;}',
'input': ' div { direction:ltr/* !rtl:ignore*/; text-align:left;}',
'reversable': false
},
{
'should': 'Should ignore white spaces before directive prefix (block-style) ',
'expected': ' div { direction:ltr; text-align:right;}',
'input': ' div {/* rtl:begin:ignore*/ direction:ltr;/* rtl:end:ignore*/ text-align:left;}',
'reversable': false
},
{
'should': 'Should ignore white spaces before directive prefix (block-style, !important comment) ',
'expected': ' div { direction:ltr; text-align:right;}',
'input': ' div {/* !rtl:begin:ignore*/ direction:ltr;/* ! rtl:end:ignore*/ text-align:left;}',
'reversable': false
}
]

@@ -36,3 +36,3 @@ /* global describe */

(function (test) {
it(test.should + ' <REVERESE>', function (done) {
it(test.should + ' <REVERSED>', function (done) {
assert.equal(rtlcss.process(test.expected, test.options, test.plugins, test.hooks), test.input)

@@ -39,0 +39,0 @@ done()

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