See #862 - allows non-standard `list-style-type`.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 24 Mar 2017 11:00:10 +0000 (12:00 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 19 Apr 2017 12:42:19 +0000 (14:42 +0200)
Why:

* `@counter-style` can define a non-standard values which should be
  treated as first class citizens.

lib/optimizer/level-2/break-up.js
lib/optimizer/validator.js
test/optimizer/level-2/break-up-test.js

index 40d5c72..45d5c31 100644 (file)
@@ -472,18 +472,19 @@ function listStyle(property, compactable, validator) {
     }
   }
 
-  // ... then `type`...
+  // ... then `position`
   for (index = 0, total = values.length; index < total; index++) {
-    if (validator.isListStyleTypeKeyword(values[index][1])) {
-      type.value = [values[index]];
+    if (validator.isListStylePositionKeyword(values[index][1])) {
+      position.value = [values[index]];
       values.splice(index, 1);
       break;
     }
   }
 
-  // ... and what's left is a `position`
-  if (values.length > 0 && validator.isListStylePositionKeyword(values[0][1]))
-    position.value = [values[0]];
+  // ... and what's left is a `type`
+  if (values.length > 0 && (validator.isListStyleTypeKeyword(values[0][1]) || validator.isIdentifier(values[0][1]))) {
+    type.value = [values[0]];
+  }
 
   return components;
 }
index cc1dc41..820f840 100644 (file)
@@ -464,8 +464,8 @@ function validator(compatibility) {
     isFunction: isFunction,
     isGlobal: isKeyword('^'),
     isHslColor: isHslColor,
-    isImage: isImage,
     isIdentifier: isIdentifier,
+    isImage: isImage,
     isKeyword: isKeyword,
     isLineHeightKeyword: isKeyword('line-height'),
     isListStylePositionKeyword: isKeyword('list-style-position'),
index e80dc26..842dc8f 100644 (file)
@@ -1767,6 +1767,32 @@ vows.describe(breakUp)
           assert.equal(components[2].name, 'list-style-image');
           assert.deepEqual(components[2].value, [['property-value', 'url(image.png)']]);
         }
+      },
+      'non-standard type': {
+        'topic': function () {
+          return _breakUp([
+            [
+              'property',
+              ['property-name', 'list-style'],
+              ['property-value', 'test']
+            ]
+          ]);
+        },
+        'has 3 components': function (components) {
+          assert.lengthOf(components, 3);
+        },
+        'has list-style-type': function (components) {
+          assert.equal(components[0].name, 'list-style-type');
+          assert.deepEqual(components[0].value, [['property-value', 'test']]);
+        },
+        'has list-style-position': function (components) {
+          assert.equal(components[1].name, 'list-style-position');
+          assert.deepEqual(components[1].value, [['property-value', 'outside']]);
+        },
+        'has list-style-image': function (components) {
+          assert.equal(components[2].name, 'list-style-image');
+          assert.deepEqual(components[2].value, [['property-value', 'none']]);
+        }
       }
     },
     'multiple values 123': {