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.
@@ -95,6 +95,7 @@ CSSStyleDeclaration.prototype = {
95
95
 
96
96
  var prevValue = this._values[name];
97
97
  delete this._values[name];
98
+ delete this._importants[name];
98
99
 
99
100
  var index = Array.prototype.indexOf.call(this, name);
100
101
  if (index < 0) {
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] = v;
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
- this._values[subprop] = obj[subprop];
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)) {
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ module.exports.definition = {
4
+ set: function (v) {
5
+ this._setProperty('align-content', v);
6
+ },
7
+ get: function () {
8
+ return this.getPropertyValue('align-content');
9
+ },
10
+ enumerable: true,
11
+ configurable: true
12
+ };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ module.exports.definition = {
4
+ set: function (v) {
5
+ this._setProperty('align-items', v);
6
+ },
7
+ get: function () {
8
+ return this.getPropertyValue('align-items');
9
+ },
10
+ enumerable: true,
11
+ configurable: true
12
+ };
@@ -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
  }
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ module.exports.definition = {
4
+ set: function (v) {
5
+ this._setProperty('flex-direction', v);
6
+ },
7
+ get: function () {
8
+ return this.getPropertyValue('flex-direction');
9
+ },
10
+ enumerable: true,
11
+ configurable: true
12
+ };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ module.exports.definition = {
4
+ set: function (v) {
5
+ this._setProperty('flex-flow', v);
6
+ },
7
+ get: function () {
8
+ return this.getPropertyValue('flex-flow');
9
+ },
10
+ enumerable: true,
11
+ configurable: true
12
+ };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ module.exports.definition = {
4
+ set: function (v) {
5
+ this._setProperty('flex-wrap', v);
6
+ },
7
+ get: function () {
8
+ return this.getPropertyValue('flex-wrap');
9
+ },
10
+ enumerable: true,
11
+ configurable: true
12
+ };
@@ -5,6 +5,9 @@ var valueType = require('../parsers').valueType;
5
5
 
6
6
  var partsRegEx = /\s*,\s*/;
7
7
  module.exports.isValid = function isValid(v) {
8
+ if (v === '' || v === null) {
9
+ return true;
10
+ }
8
11
  var parts = v.split(partsRegEx);
9
12
  var len = parts.length;
10
13
  var i;
@@ -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', parseMeasurement(v));
17
+ this._setProperty('height', parse(v));
8
18
  },
9
19
  get: function () {
10
20
  return this.getPropertyValue('height');
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ module.exports.definition = {
4
+ set: function (v) {
5
+ this._setProperty('justify-content', v);
6
+ },
7
+ get: function () {
8
+ return this.getPropertyValue('justify-content');
9
+ },
10
+ enumerable: true,
11
+ configurable: true
12
+ };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ module.exports.definition = {
4
+ set: function (v) {
5
+ this._setProperty('transform', v);
6
+ },
7
+ get: function () {
8
+ return this.getPropertyValue('transform');
9
+ },
10
+ enumerable: true,
11
+ configurable: true
12
+ };
@@ -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', parseMeasurement(v));
17
+ this._setProperty('width', parse(v));
8
18
  },
9
19
  get: function () {
10
20
  return this.getPropertyValue('width');