Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

weex-styler

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weex-styler - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

22

index.js

@@ -32,2 +32,3 @@ 'use strict'

// walk all
/* istanbul ignore else */
if (ast && ast.type === 'stylesheet' && ast.stylesheet &&

@@ -42,2 +43,20 @@ ast.stylesheet.rules && ast.stylesheet.rules.length) {

if (rule.declarations && rule.declarations.length) {
// transition shorthand parsing
var CHUNK_REGEXP = /^(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?\s*(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?$/
for (var i = 0; i < rule.declarations.length; i++) {
var declaration = rule.declarations[i]
if (declaration.property === 'transition') {
var match = declaration.value.match(CHUNK_REGEXP)
/* istanbul ignore else */
if (match) {
match[1] && rule.declarations.push({type: 'declaration', property: 'transition-property', value: match[1], position: declaration.position})
match[2] && rule.declarations.push({type: 'declaration', property: 'transition-duration', value: match[2], position: declaration.position})
match[3] && rule.declarations.push({type: 'declaration', property: 'transition-timing-function', value: match[3], position: declaration.position})
match[4] && rule.declarations.push({type: 'declaration', property: 'transition-delay', value: match[4], position: declaration.position})
rule.declarations.splice(i, 1)
break
}
}
}
rule.declarations.forEach(function (declaration) {

@@ -59,2 +78,3 @@ var subType = declaration.type

/* istanbul ignore else */
if (typeof subResult.value === 'number' || typeof subResult.value === 'string') {

@@ -112,3 +132,5 @@ ruleResult[camelCasedName] = subResult.value

}
/* istanbul ignore else */
else if (type === 'font-face') {
/* istanbul ignore else */
if (rule.declarations && rule.declarations.length) {

@@ -115,0 +137,0 @@ rule.declarations.forEach(function (declaration) {

14

lib/validator.js

@@ -174,3 +174,3 @@ var util = require('./util')

var LENGTH_REGEXP = /^[-+]?[0-9]*\.?[0-9]+(.*)$/
var LENGTH_REGEXP = /^[-+]?\d*\.?\d+(.*)$/
var SUPPORT_CSS_UNIT = ['pt']

@@ -320,3 +320,3 @@

if (v.match(/^[-+]?[0-9]+$/)) {
if (v.match(/^[-+]?\d+$/)) {
return {value: parseInt(v, 10)}

@@ -371,3 +371,3 @@ }

if (match = v.match(/^[0-9]*\.?[0-9]+(ms|s)?$/)) {
if (match = v.match(/^\d*\.?\d+(ms|s)?$/)) {
num = parseFloat(match[0])

@@ -415,4 +415,5 @@ if (!match[1]) {

var match, ret
var NUM_REGEXP = /^[-]?[0-9]*\.?[0-9]+$/
var NUM_REGEXP = /^[-]?\d*\.?\d+$/
if (match = v.match(/^cubic-bezier\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*\)$/)) {
/* istanbul ignore else */
if (match[1].match(NUM_REGEXP) && match[2].match(NUM_REGEXP) && match[3].match(NUM_REGEXP) && match[4].match(NUM_REGEXP)) {

@@ -571,3 +572,5 @@ ret = [parseFloat(match[1]), parseFloat(match[2]), parseFloat(match[3]), parseFloat(match[4])].join(',')

result = validator(value)
} else {
}
/* istanbul ignore else */
else {
result = {value: value}

@@ -581,2 +584,3 @@ }

// ensure number type, no `px`
/* istanbul ignore else */
if (typeof value !== 'function') {

@@ -583,0 +587,0 @@ var match = value.match(LENGTH_REGEXP)

{
"name": "weex-styler",
"version": "0.1.5",
"version": "0.1.6",
"description": "Weex <style> transformer",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -110,2 +110,21 @@ var chai = require('chai')

it('parse transition shorthand', function (done) {
var code = '.foo {font-size: 20; transition: margin-top 500ms ease-in-out 1s}'
styler.parse(code, function (err, data) {
expect(err).is.undefined
expect(data).is.an.object
expect(data.jsonStyle).eql({
'@TRANSITION': {
foo: {property: 'marginTop', duration: 500, delay: 1000, timingFunction: 'ease-in-out'},
},
foo: {fontSize: 20}
})
expect(data.log).eql([
{line: 1, column: 22, reason: 'NOTE: property value `500ms` is autofixed to `500`'},
{line: 1, column: 22, reason: 'NOTE: property value `1s` is autofixed to `1000`'}
])
done()
})
})
it('handle pseudo class', function (done) {

@@ -112,0 +131,0 @@ var code = '.class-a {color: #0000ff;} .class-a:last-child:focus {color: #ff0000;}'

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