Simplifies compatibility mode definitions.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Tue, 27 Dec 2016 15:51:40 +0000 (16:51 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Tue, 27 Dec 2016 15:51:40 +0000 (16:51 +0100)
Why:

* Using inheritance it's clear which properties change.

lib/utils/compatibility.js

index d343a98..7e37cd9 100644 (file)
@@ -37,82 +37,40 @@ var DEFAULTS = {
       vmin: true,
       vw: true
     }
+  }
+};
+
+DEFAULTS.ie8 = merge(DEFAULTS['*'], {
+  colors: {
+    opacity: false
   },
-  'ie8': {
-    colors: {
-      opacity: false
-    },
-    properties: {
-      backgroundClipMerging: false,
-      backgroundOriginMerging: false,
-      backgroundSizeMerging: false,
-      colors: true,
-      fontWeight: true,
-      ieBangHack: false,
-      iePrefixHack: true,
-      ieSuffixHack: true,
-      merging: false,
-      shorterLengthUnits: false,
-      spaceAfterClosingBrace: true,
-      urlQuotes: false,
-      zeroUnits: true
-    },
-    selectors: {
-      adjacentSpace: false,
-      ie7Hack: false,
-      special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow|^,)/
-    },
-    units: {
-      ch: false,
-      in: true,
-      pc: true,
-      pt: true,
-      rem: false,
-      vh: false,
-      vm: false,
-      vmax: false,
-      vmin: false,
-      vw: false
-    }
+  properties: {
+    iePrefixHack: true,
+    merging: false
   },
-  'ie7': {
-    colors: {
-      opacity: false
-    },
-    properties: {
-      backgroundClipMerging: false,
-      backgroundOriginMerging: false,
-      backgroundSizeMerging: false,
-      colors: true,
-      fontWeight: true,
-      ieBangHack: true,
-      iePrefixHack: true,
-      ieSuffixHack: true,
-      merging: false,
-      shorterLengthUnits: false,
-      spaceAfterClosingBrace: true,
-      urlQuotes: false,
-      zeroUnits: true
-    },
-    selectors: {
-      adjacentSpace: false,
-      ie7Hack: true,
-      special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow|^,)/
-    },
-    units: {
-      ch: false,
-      in: true,
-      pc: true,
-      pt: true,
-      rem: false,
-      vh: false,
-      vm: false,
-      vmax: false,
-      vmin: false,
-      vw: false,
-    }
+  selectors: {
+    special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow|^,)/
+  },
+  units: {
+    ch: false,
+    rem: false,
+    vh: false,
+    vm: false,
+    vmax: false,
+    vmin: false,
+    vw: false
   }
-};
+});
+
+DEFAULTS.ie7 = merge(DEFAULTS.ie8, {
+  properties: {
+    ieBangHack: true
+  },
+  selectors: {
+    ie7Hack: true,
+    special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow|^,)/
+  },
+});
 
 function compatibility(source) {
   return merge(DEFAULTS['*'], calculateSource(source));