weex-styler
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -516,2 +516,31 @@ var util = require('./util') | ||
function FLEW_WRAP_VALIDATOR (v) { | ||
var list = ['nowrap', 'wrap', 'wrap-reverse'] | ||
var index = list.indexOf(v) | ||
if (index > 0) { | ||
return { | ||
value: v, | ||
reason: function reason(k, v, result) { | ||
return 'NOTE: the ' + util.camelCaseToHyphened(k) + ' property may have compatibility problem on native' | ||
} | ||
} | ||
} | ||
if (index === 0) { | ||
return { | ||
value: v, | ||
reason: function reason(k, v, result) { | ||
return 'NOTE: property value `' + v + '` is the DEFAULT value for `' + util.camelCaseToHyphened(k) + '` (could be removed)' | ||
} | ||
} | ||
} | ||
else { | ||
return { | ||
value: null, | ||
reason: function reason(k, v, result) { | ||
return 'ERROR: property value `' + v + '` is not supported for `' + util.camelCaseToHyphened(k) + '` (supported values are: `' + list.join('`|`') + '`)' | ||
} | ||
} | ||
} | ||
} | ||
var PROP_NAME_GROUPS = { | ||
@@ -555,2 +584,3 @@ boxModel: { | ||
flex: NUMBER_VALIDATOR, | ||
flexWrap: FLEW_WRAP_VALIDATOR, | ||
flexDirection: genEnumValidator(['column', 'row']), | ||
@@ -557,0 +587,0 @@ justifyContent: genEnumValidator(['flex-start', 'flex-end', 'center', 'space-between','space-around']), |
{ | ||
"name": "weex-styler", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "Weex <style> transformer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -207,15 +207,27 @@ var chai = require('chai') | ||
it('parse enum', function (done) { | ||
it('parse color', function (done) { | ||
var code = { | ||
foo: { | ||
position: 'absolute' | ||
color: '#FF0000', | ||
backgroundColor: '#ff0000' | ||
}, | ||
bar: { | ||
position: 'relative' | ||
color: '#F00', | ||
backgroundColor: '#f00' | ||
}, | ||
baz: { | ||
position: 'fixed' | ||
color: 'red', | ||
backgroundColor: 'lightpink' | ||
}, | ||
boo: { | ||
position: '' | ||
rgba: { | ||
color: 'rgb(23, 0, 255)', | ||
backgroundColor: 'rgba(234, 45, 99, .4)' | ||
}, | ||
transparent: { | ||
color: 'transparent', | ||
backgroundColor: 'asdf' | ||
}, | ||
errRgba: { | ||
color: 'rgb(266,0,255)', | ||
backgroundColor: 'rgba(234,45,99,1.3)' | ||
} | ||
@@ -228,15 +240,30 @@ } | ||
foo: { | ||
position: 'absolute' | ||
color: '#FF0000', | ||
backgroundColor: '#ff0000' | ||
}, | ||
bar: { | ||
position: 'relative' | ||
color: '#FF0000', | ||
backgroundColor: '#ff0000' | ||
}, | ||
baz: { | ||
position: 'fixed' | ||
color: '#FF0000', | ||
backgroundColor: '#FFB6C1' | ||
}, | ||
boo: {} | ||
rgba: { | ||
color: 'rgb(23,0,255)', | ||
backgroundColor: 'rgba(234,45,99,0.4)' | ||
}, | ||
transparent: { | ||
color: 'rgba(0,0,0,0)' | ||
}, | ||
errRgba: {} | ||
}) | ||
expect(data.log).eql([ | ||
{reason: 'NOTE: property value `relative` is the DEFAULT value for `position` (could be removed)'}, | ||
{reason: 'ERROR: property value `` is not supported for `position` (supported values are: `relative`|`absolute`|`sticky`|`fixed`)'} | ||
{reason: 'NOTE: property value `#F00` is autofixed to `#FF0000`'}, | ||
{reason: 'NOTE: property value `#f00` is autofixed to `#ff0000`'}, | ||
{reason: 'NOTE: property value `red` is autofixed to `#FF0000`'}, | ||
{reason: 'NOTE: property value `lightpink` is autofixed to `#FFB6C1`'}, | ||
{reason: 'ERROR: property value `asdf` is not valid for `background-color`'}, | ||
{reason: 'ERROR: property value `rgb(266,0,255)` is not valid for `color`'}, | ||
{reason: 'ERROR: property value `rgba(234,45,99,1.3)` is not valid for `background-color`'} | ||
]) | ||
@@ -247,2 +274,22 @@ done() | ||
it('parse flex-wrap', function (done) { | ||
var code = { | ||
foo: { flexWrap: 'nowrap' }, | ||
bar: { flexWrap: 'wrap' } | ||
} | ||
styler.validate(code, function (err, data) { | ||
expect(err).is.undefined | ||
expect(data).is.an.object | ||
expect(data.jsonStyle).eql({ | ||
foo: { flexWrap: 'nowrap' }, | ||
bar: { flexWrap: 'wrap' } | ||
}) | ||
expect(data.log).eql([ | ||
{reason: 'NOTE: property value `nowrap` is the DEFAULT value for `flex-wrap` (could be removed)'}, | ||
{reason: 'NOTE: the flex-wrap property may have compatibility problem on native'}, | ||
]) | ||
done() | ||
}) | ||
}) | ||
it('parse transition-property', function (done) { | ||
@@ -249,0 +296,0 @@ var code = { |
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
63251
1847