[Pkg-javascript-commits] [node-cssstyle] 25/39: fixed top, bottom, left and right (and a couple former tests)

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Sep 20 19:37:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository node-cssstyle.

commit e48d60502b565f2abade45d634fe9dff76afcbc9
Author: Chad Walker <chad at chad-cat-lore-eddie.com>
Date:   Sun Dec 1 21:10:24 2013 -0600

    fixed top, bottom, left and right (and a couple former tests)
---
 lib/parsers.js           |  2 +-
 lib/properties/bottom.js |  4 +++-
 lib/properties/left.js   |  4 +++-
 lib/properties/right.js  |  4 +++-
 lib/properties/top.js    |  4 +++-
 tests/tests.js           | 27 +++++++++++++++++++++------
 6 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/lib/parsers.js b/lib/parsers.js
index e123fb7..32d8dcb 100644
--- a/lib/parsers.js
+++ b/lib/parsers.js
@@ -21,7 +21,7 @@ exports.TYPES = {
 // rough regular expressions
 var integerRegEx = /^[\-+]?[0-9]+$/;
 var numberRegEx = /^[\-+]?[0-9]*\.[0-9]+$/;
-var lengthRegEx = /^(0|[\-+]?[0-9]?\.?[0-9]+(in|cm|mm|pt|pc|px))$/;
+var lengthRegEx = /^(0|[\-+]?[0-9]?\.?[0-9]+(in|cm|em|mm|pt|pc|px))$/;
 var percentRegEx = /^[\-+]?[0-9]?\.?[0-9]+%$/;
 var urlRegEx = /^url\(\s*([^\)]*)\s*\)$/;
 var stringRegEx = /^("[^"]*"|'[^']*')$/;
diff --git a/lib/properties/bottom.js b/lib/properties/bottom.js
index 941efca..11e446c 100644
--- a/lib/properties/bottom.js
+++ b/lib/properties/bottom.js
@@ -1,8 +1,10 @@
 'use strict';
 
+var parseMeasurement = require('../parsers').parseMeasurement;
+
 module.exports.definition = {
     set: function (v) {
-        this.setProperty('bottom', v);
+        this.setProperty('bottom', parseMeasurement(v));
     },
     get: function () {
         return this.getPropertyValue('bottom');
diff --git a/lib/properties/left.js b/lib/properties/left.js
index a398d9f..22076c9 100644
--- a/lib/properties/left.js
+++ b/lib/properties/left.js
@@ -1,8 +1,10 @@
 'use strict';
 
+var parseMeasurement = require('../parsers').parseMeasurement;
+
 module.exports.definition = {
     set: function (v) {
-        this.setProperty('left', v);
+        this.setProperty('left', parseMeasurement(v));
     },
     get: function () {
         return this.getPropertyValue('left');
diff --git a/lib/properties/right.js b/lib/properties/right.js
index b44ad6c..35ac3f3 100644
--- a/lib/properties/right.js
+++ b/lib/properties/right.js
@@ -1,8 +1,10 @@
 'use strict';
 
+var parseMeasurement = require('../parsers').parseMeasurement;
+
 module.exports.definition = {
     set: function (v) {
-        this.setProperty('right', v);
+        this.setProperty('right', parseMeasurement(v));
     },
     get: function () {
         return this.getPropertyValue('right');
diff --git a/lib/properties/top.js b/lib/properties/top.js
index 5d94282..77a28d3 100644
--- a/lib/properties/top.js
+++ b/lib/properties/top.js
@@ -1,8 +1,10 @@
 'use strict';
 
+var parseMeasurement = require('../parsers').parseMeasurement;
+
 module.exports.definition = {
     set: function (v) {
-        this.setProperty('top', v);
+        this.setProperty('top', parseMeasurement(v));
     },
     get: function () {
         return this.getPropertyValue('top');
diff --git a/tests/tests.js b/tests/tests.js
index 3ee25e4..ca2e34c 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -113,13 +113,28 @@ module.exports = {
         var style = new cssstyle.CSSStyleDeclaration();
         test.expect(7);
         style.borderWidth = 0;
-        test.ok(style.length === 1, 'length is not 1');
-        test.ok('0px', style.borderWidth, 'borderWidth is not 0px');
-        test.ok('0px', style.borderTopWidth, 'borderTopWidth is not 0px');
-        test.ok('0px', style.borderBottomWidth, 'borderBottomWidth is not 0px');
-        test.ok('0px', style.borderLeftWidth, 'borderLeftWidth is not 0px');
-        test.ok('0px', style.borderRightWidth, 'borderRightWidth is not 0px');
+        test.ok(1 === style.length, 'length is not 1');
+        test.ok('0px' === style.borderWidth, 'borderWidth is not 0px');
+        test.ok('0px' === style.borderTopWidth, 'borderTopWidth is not 0px');
+        test.ok('0px' === style.borderBottomWidth, 'borderBottomWidth is not 0px');
+        test.ok('0px' === style.borderLeftWidth, 'borderLeftWidth is not 0px');
+        test.ok('0px' === style.borderRightWidth, 'borderRightWidth is not 0px');
         test.ok('border-width: 0px;' === style.cssText, 'cssText is not "border-width: 0px", "' + style.cssText + '"');
         test.done();
+    },
+    'Test Top, Left, Right, Bottom Properties': function (test) {
+        var style = new cssstyle.CSSStyleDeclaration();
+        test.expect(6);
+        style.top = 0;
+        style.left = '0%';
+        style.right = '5em';
+        style.bottom = '12pt';
+        test.ok('0px' === style.top, 'top is not 0px');
+        test.ok('0%' === style.left, 'left is not 0%');
+        test.ok('5em' === style.right, 'right is not 5em');
+        test.ok('12pt' === style.bottom, 'bottom is not 12pt');
+        test.ok(4 === style.length, 'length is not 4');
+        test.ok('top: 0px; left: 0%; right: 5em; bottom: 12pt;' === style.cssText, 'text is not "top: 0px; left: 0%; right: 5em; bottom: 12pt;"');
+        test.done();
     }
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-cssstyle.git



More information about the Pkg-javascript-commits mailing list