stylelint-gamut 1.2.8 → 1.2.9

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/utils.js +13 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylelint-gamut",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "Stylelint plugin for working with different color spaces",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/utils.js CHANGED
@@ -28,14 +28,6 @@ function declarationValueIndex (decl) {
28
28
  }, 0)
29
29
  }
30
30
 
31
- /**
32
- * @param {Node} node
33
- * @returns {node is import('postcss').AtRule}
34
- */
35
- function isAtRule (node) {
36
- return node.type === 'atrule'
37
- }
38
-
39
31
  /**
40
32
  * Check whether a property is standard
41
33
  *
@@ -94,13 +86,21 @@ function isInColorGamutRec2020MediaQuery (decl) {
94
86
  * @returns {boolean | decl}
95
87
  */
96
88
  function getMediaQueryParent (decl) {
97
- if (decl.parent && decl.parent.parent && isAtRule(decl.parent.parent)) {
98
- const parent = decl.parent.parent
89
+ let parent = decl.parent
99
90
 
100
- return parent.name === 'media' && parent
101
- }
91
+ if (parent && isMediaQuery(parent)) return parent
102
92
 
103
- return false
93
+ parent = parent.parent
94
+
95
+ return isMediaQuery(parent) && parent
96
+ }
97
+
98
+ /**
99
+ * @param {import('postcss').Declaration} decl
100
+ * @returns {boolean}
101
+ */
102
+ function isMediaQuery (decl) {
103
+ return decl.type === 'atrule' && decl.name === 'media'
104
104
  }
105
105
 
106
106
  module.exports = {