postcss-merge-rules 4.0.2 → 4.0.3

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.
@@ -73,6 +73,21 @@ function isCssMixin(selector) {
73
73
  return selector[selector.length - 1] === ':';
74
74
  }
75
75
 
76
+ const isSupportedCache = {};
77
+
78
+ // Move to util in future
79
+ function isSupportedCached(feature, browsers) {
80
+ const key = JSON.stringify({ feature, browsers });
81
+ let result = isSupportedCache[key];
82
+
83
+ if (!result) {
84
+ result = (0, _caniuseApi.isSupported)(feature, browsers);
85
+ isSupportedCache[key] = result;
86
+ }
87
+
88
+ return result;
89
+ }
90
+
76
91
  function ensureCompatibility(selectors, browsers, compatibilityCache) {
77
92
  // Should not merge mixins
78
93
  if (selectors.some(isCssMixin)) {
@@ -92,37 +107,37 @@ function ensureCompatibility(selectors, browsers, compatibilityCache) {
92
107
  if (type === 'pseudo') {
93
108
  const entry = pseudoElements[value];
94
109
  if (entry && compatible) {
95
- compatible = (0, _caniuseApi.isSupported)(entry, browsers);
110
+ compatible = isSupportedCached(entry, browsers);
96
111
  }
97
112
  }
98
113
  if (type === 'combinator') {
99
114
  if (~value.indexOf('~')) {
100
- compatible = (0, _caniuseApi.isSupported)(cssSel3, browsers);
115
+ compatible = isSupportedCached(cssSel3, browsers);
101
116
  }
102
117
  if (~value.indexOf('>') || ~value.indexOf('+')) {
103
- compatible = (0, _caniuseApi.isSupported)(cssSel2, browsers);
118
+ compatible = isSupportedCached(cssSel2, browsers);
104
119
  }
105
120
  }
106
121
  if (type === 'attribute' && node.attribute) {
107
122
  // [foo]
108
123
  if (!node.operator) {
109
- compatible = (0, _caniuseApi.isSupported)(cssSel2, browsers);
124
+ compatible = isSupportedCached(cssSel2, browsers);
110
125
  }
111
126
 
112
127
  if (value) {
113
128
  // [foo="bar"], [foo~="bar"], [foo|="bar"]
114
129
  if (~['=', '~=', '|='].indexOf(node.operator)) {
115
- compatible = (0, _caniuseApi.isSupported)(cssSel2, browsers);
130
+ compatible = isSupportedCached(cssSel2, browsers);
116
131
  }
117
132
  // [foo^="bar"], [foo$="bar"], [foo*="bar"]
118
133
  if (~['^=', '$=', '*='].indexOf(node.operator)) {
119
- compatible = (0, _caniuseApi.isSupported)(cssSel3, browsers);
134
+ compatible = isSupportedCached(cssSel3, browsers);
120
135
  }
121
136
  }
122
137
 
123
138
  // [foo="bar" i]
124
139
  if (node.insensitive) {
125
- compatible = (0, _caniuseApi.isSupported)('css-case-insensitive', browsers);
140
+ compatible = isSupportedCached('css-case-insensitive', browsers);
126
141
  }
127
142
  }
128
143
  if (!compatible) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-merge-rules",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "Merge CSS rules with PostCSS.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
package/CHANGELOG.md DELETED
@@ -1,148 +0,0 @@
1
- # 4.0.0-rc.0
2
-
3
- * Breaking: Drops support for Node 0.12, we now require at least Node 4.
4
- * Breaking: Update PostCSS to 6.0.0.
5
- * Update Browserslist to 2.0.0.
6
-
7
- # 2.1.2
8
-
9
- * Performance improvements; no compatibility checking for simple selectors,
10
- cached compatibility lookups, and early exit on compatibility mismatches
11
- (thanks to @akx).
12
-
13
- # 2.1.1
14
-
15
- * Resolves an issue with `2.1.0` where `browserslist` was not being installed
16
- correctly on older Node versions.
17
-
18
- # 2.1.0
19
-
20
- * Rules are now merged based on supported browsers, which uses `browserslist`
21
- & `caniuse-api`. The browsers should be supplied by the standard means of
22
- [configuring `browserslist`][browserslist], either using config files or
23
- via environment variables.
24
-
25
- [browserslist]: https://github.com/ai/browserslist#config-file
26
-
27
- # 2.0.11
28
-
29
- * Resolves an issue where partially identical properties would be removed from
30
- a rule erroneously; for example `color: #fff` would be removed if the other
31
- rule contained `background-color: #fff`.
32
-
33
- # 2.0.10
34
-
35
- * Replaces the internal list of vendor prefixes with the `vendors` module
36
- (now, some less widely used prefixes are supported).
37
-
38
- # 2.0.9
39
-
40
- * Resolves an issue where the module would merge rules that had colliding
41
- vendor prefixed properties and specification properties.
42
-
43
- # 2.0.8
44
-
45
- * Resolves an issue where selectors inside `@keyframes` would be merged,
46
- causing a break in Safari.
47
-
48
- # 2.0.7
49
-
50
- * Resolves an issue where merging was not respecting property order, in cases
51
- where both shorthand definitions and longhand definitions existed. Now,
52
- these cases will not be merged (thanks to @11bit).
53
-
54
- # 2.0.6
55
-
56
- * Fixes an issue where forward merging was not checking that the merge candidate
57
- was safe to merge (either contains no vendor prefixes,
58
- or the same vendor prefixes).
59
-
60
- # 2.0.5
61
-
62
- * Replaced PostCSS' `cloneBefore` with custom clone method to handle `null`
63
- values properly.
64
-
65
- # 2.0.4
66
-
67
- * Fixes a crash when cloning a `null` object property (thanks to @JMoxey).
68
-
69
- # 2.0.3
70
-
71
- * Fixed an issue where the module was incorrectly merging across `@font-face`
72
- at-rules.
73
-
74
- # 2.0.2
75
-
76
- * Fixed an issue where keyframes with the same name were being merged together
77
- incorrectly.
78
-
79
- # 2.0.1
80
-
81
- * Fixed a crash when `rule.nodes` was not defined.
82
-
83
- # 2.0.0
84
-
85
- * Upgraded to PostCSS 5.
86
-
87
- # 1.3.6
88
-
89
- * Minor boost in performance with reduced stringify passes.
90
-
91
- # 1.3.5
92
-
93
- * Improves merging of adjacent rules with identical selectors.
94
-
95
- # 1.3.4
96
-
97
- * Fixes an issue where in some cases, non-adjacent rule merging was being
98
- performed.
99
-
100
- # 1.3.3
101
-
102
- * Fixes an issue where the wildcard hack (`*zoom: 1`) was being propagated to
103
- other properties erroneously.
104
- * Better merging logic in some cases.
105
-
106
- # 1.3.2
107
-
108
- * Fixes a behaviour in which comment nodes were being processed by the
109
- partial declaration merging logic.
110
-
111
- # 1.3.1
112
-
113
- * Fixes a behaviour in which rule adjacent forward nodes were not being type
114
- checked before they were merged.
115
- * Compatibility fixes for the PostCSS plugin guidelines.
116
-
117
- # 1.3.0
118
-
119
- * Better support for merging properties without the existance of a shorthand
120
- override.
121
- * Can now 'merge forward' adjacent rules as well as the previous 'merge behind'
122
- behaviour, leading to better compression.
123
-
124
- # 1.2.2
125
-
126
- * Fixed an issue where the plugin crashed if node.parent was undefined.
127
-
128
- # 1.2.1
129
-
130
- * Fixed a bug where media queries were being merged when their parameters were
131
- different.
132
-
133
- # 1.2.0
134
-
135
- * Now uses the PostCSS `4.1` plugin API.
136
-
137
- # 1.1.1
138
-
139
- * Bugfix of last release, now difference is calculated in both directions.
140
-
141
- # 1.1.0
142
-
143
- * Less eager moving of properties, to avoid cases where moving a longhand
144
- property would allow a shorthand property to override it.
145
-
146
- # 1.0.0
147
-
148
- * Initial release.