Fixes #480 - uppercase properties in reordering.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Thu, 5 Mar 2015 06:54:40 +0000 (06:54 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Thu, 5 Mar 2015 06:54:40 +0000 (06:54 +0000)
It's an edge case but we should support it nonetheless.

History.md
lib/properties/extractor.js
test/properties/reorderable-test.js

index b8de1eb..ec4ce37 100644 (file)
@@ -2,6 +2,7 @@
 ==================
 
 * Fixed issue [#396](https://github.com/jakubpawlowicz/clean-css/issues/396) - better input source maps tracking.
+* Fixed issue [#480](https://github.com/jakubpawlowicz/clean-css/issues/480) - extracting upcase property names.
 
 [3.1.4 / 2015-03-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.3...v3.1.4)
 ==================
index c675efe..69156c3 100644 (file)
@@ -47,7 +47,7 @@ function findNameRoot(name) {
   if (name.indexOf('text-') === 0)
     return name;
 
-  return name.replace(/^\-\w+\-/, '').match(/([a-z]+)/)[0];
+  return name.replace(/^\-\w+\-/, '').match(/([a-zA-Z]+)/)[0].toLowerCase();
 }
 
 module.exports = extract;
index 4450b25..56dde86 100644 (file)
@@ -53,10 +53,18 @@ vows.describe(canReorderSingle)
       'topic': canReorderSingle(propertiesIn('a{color:red}')[0], propertiesIn('a{color:red}')[0]),
       'must be true': function (result) { assert.isTrue(result); }
     },
+    'same properties with same value and different case': {
+      'topic': canReorderSingle(propertiesIn('a{COLOR:red}')[0], propertiesIn('a{color:red}')[0]),
+      'must be true': function (result) { assert.isTrue(result); }
+    },
     'same properties with different value': {
       'topic': canReorderSingle(propertiesIn('a{color:red}')[0], propertiesIn('a{color:blue}')[0]),
       'must be false': function (result) { assert.isFalse(result); }
     },
+    'same properties with different value and different case': {
+      'topic': canReorderSingle(propertiesIn('a{color:red}')[0], propertiesIn('a{COLOR:blue}')[0]),
+      'must be false': function (result) { assert.isFalse(result); }
+    },
     'different properties with same root': {
       'topic': canReorderSingle(propertiesIn('a{text-shadow:none}')[0], propertiesIn('a{text-decoration:underline}')[0]),
       'must be true': function (result) { assert.isTrue(result); }