cssstyle 1.1.0 → 1.1.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/parsers.js +1 -1
- package/package.json +2 -2
- package/tests/tests.js +8 -4
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|ex|rem))$/;
|
|
24
|
+
var lengthRegEx = /^(0|[\-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw))$/;
|
|
25
25
|
var percentRegEx = /^[\-+]?[0-9]*\.?[0-9]+%$/;
|
|
26
26
|
var urlRegEx = /^url\(\s*([^\)]*)\s*\)$/;
|
|
27
27
|
var stringRegEx = /^(\"[^\"]*\"|\'[^\']*\')$/;
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"CSSStyleDeclaration",
|
|
7
7
|
"StyleSheet"
|
|
8
8
|
],
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.1",
|
|
10
10
|
"homepage": "https://github.com/jsakas/CSSStyleDeclaration",
|
|
11
11
|
"maintainers": [
|
|
12
12
|
{
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"test": "node ./scripts/generate_properties.js && node ./scripts/generate_valid_properties.js && nodeunit tests",
|
|
54
|
-
"
|
|
54
|
+
"prepare": "node ./scripts/generate_properties.js && node ./scripts/generate_valid_properties.js"
|
|
55
55
|
},
|
|
56
56
|
"license": "MIT"
|
|
57
57
|
}
|
package/tests/tests.js
CHANGED
|
@@ -56,9 +56,9 @@ module.exports = {
|
|
|
56
56
|
'Test From Style String': function (test) {
|
|
57
57
|
var style = new cssstyle.CSSStyleDeclaration();
|
|
58
58
|
test.expect(8);
|
|
59
|
-
style.cssText = 'color: blue; background-color: red; width: 78
|
|
60
|
-
test.ok(
|
|
61
|
-
test.ok('color: blue; background-color: red; width: 78%;' === style.cssText, 'cssText is wrong');
|
|
59
|
+
style.cssText = 'color: blue; background-color: red; width: 78%; height: 50vh;';
|
|
60
|
+
test.ok(4 === style.length, 'length is not 4');
|
|
61
|
+
test.ok('color: blue; background-color: red; width: 78%; height: 50vh;' === style.cssText, 'cssText is wrong');
|
|
62
62
|
test.ok('blue' === style.getPropertyValue('color'), "getPropertyValue('color') failed");
|
|
63
63
|
test.ok('color' === style.item(0), 'item(0) failed');
|
|
64
64
|
test.ok('background-color' === style[1], 'style[1] failed');
|
|
@@ -108,13 +108,17 @@ module.exports = {
|
|
|
108
108
|
},
|
|
109
109
|
'Test width and height Properties and null and empty strings': function (test) {
|
|
110
110
|
var style = new cssstyle.CSSStyleDeclaration();
|
|
111
|
-
test.expect(
|
|
111
|
+
test.expect(9);
|
|
112
112
|
style.height = 6;
|
|
113
113
|
test.ok('' === style.height, 'height does not remain unset');
|
|
114
114
|
style.width = 0;
|
|
115
115
|
test.ok('0px' === style.width, 'width is not 0px');
|
|
116
116
|
style.height = '34%';
|
|
117
117
|
test.ok('34%' === style.height, 'height is not 34%');
|
|
118
|
+
style.height = '100vh';
|
|
119
|
+
test.ok('100vh' === style.height, 'height is not 100vh');
|
|
120
|
+
style.height = '100vw';
|
|
121
|
+
test.ok('100vw' === style.height, 'height is not 100vw');
|
|
118
122
|
style.height = '';
|
|
119
123
|
test.ok(style.length === 1, 'length is not 1');
|
|
120
124
|
test.ok('width: 0px;' === style.cssText, 'cssText is not "width: 0px;"');
|