cssstyle 0.2.34 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/CSSStyleDeclaration.js +1 -0
- package/lib/parsers.js +6 -3
- package/lib/properties/alignContent.js +12 -0
- package/lib/properties/alignItems.js +12 -0
- package/lib/properties/backgroundPosition.js +3 -0
- package/lib/properties/borderSpacing.js +3 -0
- package/lib/properties/flexDirection.js +12 -0
- package/lib/properties/flexFlow.js +12 -0
- package/lib/properties/flexWrap.js +12 -0
- package/lib/properties/fontFamily.js +3 -0
- package/lib/properties/height.js +11 -1
- package/lib/properties/justifyContent.js +12 -0
- package/lib/properties/transform.js +12 -0
- package/lib/properties/width.js +11 -1
- package/lib/properties.js +5937 -1129
- package/package.json +52 -30
- package/scripts/generate_properties.js +283 -14
- package/tests/tests.js +40 -0
- package/.npmignore +0 -1
package/lib/parsers.js
CHANGED
|
@@ -21,7 +21,7 @@ exports.TYPES = {
|
|
|
21
21
|
// rough regular expressions
|
|
22
22
|
var integerRegEx = /^[\-+]?[0-9]+$/;
|
|
23
23
|
var numberRegEx = /^[\-+]?[0-9]*\.[0-9]+$/;
|
|
24
|
-
var lengthRegEx = /^(0|[\-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px))$/;
|
|
24
|
+
var lengthRegEx = /^(0|[\-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px|ex|rem))$/;
|
|
25
25
|
var percentRegEx = /^[\-+]?[0-9]*\.?[0-9]+%$/;
|
|
26
26
|
var urlRegEx = /^url\(\s*([^\)]*)\s*\)$/;
|
|
27
27
|
var stringRegEx = /^(\"[^\"]*\"|\'[^\']*\')$/;
|
|
@@ -470,7 +470,7 @@ exports.shorthandParser = function parse(v, shorthand_for) {
|
|
|
470
470
|
var type = exports.valueType(v);
|
|
471
471
|
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
|
|
472
472
|
Object.keys(shorthand_for).forEach(function (property) {
|
|
473
|
-
obj[property] =
|
|
473
|
+
obj[property] = '';
|
|
474
474
|
});
|
|
475
475
|
return obj;
|
|
476
476
|
}
|
|
@@ -519,7 +519,10 @@ exports.shorthandSetter = function (property, shorthand_for) {
|
|
|
519
519
|
// in case it gets translated into something else (0 -> 0px)
|
|
520
520
|
obj[subprop] = this[camel];
|
|
521
521
|
this.removeProperty(subprop);
|
|
522
|
-
|
|
522
|
+
// don't add in empty properties
|
|
523
|
+
if (obj[subprop] !== '') {
|
|
524
|
+
this._values[subprop] = obj[subprop];
|
|
525
|
+
}
|
|
523
526
|
}, this);
|
|
524
527
|
Object.keys(shorthand_for).forEach(function (subprop) {
|
|
525
528
|
if (!obj.hasOwnProperty(subprop)) {
|
|
@@ -5,6 +5,9 @@ var parsers = require('../parsers');
|
|
|
5
5
|
var valid_keywords = ['top', 'center', 'bottom', 'left', 'right'];
|
|
6
6
|
|
|
7
7
|
var parse = function parse(v) {
|
|
8
|
+
if (v === '' || v === null) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
8
11
|
var parts = v.split(/\s+/);
|
|
9
12
|
if (parts.length > 2 || parts.length < 1) {
|
|
10
13
|
return undefined;
|
|
@@ -7,6 +7,9 @@ var parsers = require('../parsers');
|
|
|
7
7
|
// if two, the first applies to the horizontal and the second applies to vertical spacing
|
|
8
8
|
|
|
9
9
|
var parse = function parse(v) {
|
|
10
|
+
if (v === '' || v === null) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
10
13
|
if (v.toLowerCase() === 'inherit') {
|
|
11
14
|
return v;
|
|
12
15
|
}
|
package/lib/properties/height.js
CHANGED
|
@@ -2,9 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var parseMeasurement = require('../parsers').parseMeasurement;
|
|
4
4
|
|
|
5
|
+
function parse(v) {
|
|
6
|
+
if (String(v).toLowerCase() === 'auto') {
|
|
7
|
+
return 'auto';
|
|
8
|
+
}
|
|
9
|
+
if (String(v).toLowerCase() === 'inherit') {
|
|
10
|
+
return 'inherit';
|
|
11
|
+
}
|
|
12
|
+
return parseMeasurement(v);
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
module.exports.definition = {
|
|
6
16
|
set: function (v) {
|
|
7
|
-
this._setProperty('height',
|
|
17
|
+
this._setProperty('height', parse(v));
|
|
8
18
|
},
|
|
9
19
|
get: function () {
|
|
10
20
|
return this.getPropertyValue('height');
|
package/lib/properties/width.js
CHANGED
|
@@ -2,9 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var parseMeasurement = require('../parsers').parseMeasurement;
|
|
4
4
|
|
|
5
|
+
function parse(v) {
|
|
6
|
+
if (String(v).toLowerCase() === 'auto') {
|
|
7
|
+
return 'auto';
|
|
8
|
+
}
|
|
9
|
+
if (String(v).toLowerCase() === 'inherit') {
|
|
10
|
+
return 'inherit';
|
|
11
|
+
}
|
|
12
|
+
return parseMeasurement(v);
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
module.exports.definition = {
|
|
6
16
|
set: function (v) {
|
|
7
|
-
this._setProperty('width',
|
|
17
|
+
this._setProperty('width', parse(v));
|
|
8
18
|
},
|
|
9
19
|
get: function () {
|
|
10
20
|
return this.getPropertyValue('width');
|