(config: { unitlessMqAlwaysFirst?: boolean } = {})
| 128 | // ---------------------------------------- |
| 129 | |
| 130 | function createSort(config: { unitlessMqAlwaysFirst?: boolean } = {}) { |
| 131 | const { unitlessMqAlwaysFirst } = config |
| 132 | |
| 133 | return function sortCSSmq(a: string, b: string) { |
| 134 | const testIsPrint = _testIsPrint(a, b) |
| 135 | if (testIsPrint !== null) { |
| 136 | return testIsPrint |
| 137 | } |
| 138 | |
| 139 | const minA = isMinWidth(a) || isMinHeight(a) |
| 140 | const maxA = isMaxWidth(a) || isMaxHeight(a) |
| 141 | |
| 142 | const minB = isMinWidth(b) || isMinHeight(b) |
| 143 | const maxB = isMaxWidth(b) || isMaxHeight(b) |
| 144 | |
| 145 | if (unitlessMqAlwaysFirst && ((!minA && !maxA) || (!minB && !maxB))) { |
| 146 | if (!minA && !maxA && !minB && !maxB) { |
| 147 | return a.localeCompare(b) |
| 148 | } |
| 149 | return !minB && !maxB ? 1 : -1 |
| 150 | } else { |
| 151 | if (minA && maxB) { |
| 152 | return -1 |
| 153 | } |
| 154 | if (maxA && minB) { |
| 155 | return 1 |
| 156 | } |
| 157 | |
| 158 | const lengthA = getQueryLength(a) |
| 159 | const lengthB = getQueryLength(b) |
| 160 | |
| 161 | if (lengthA === maxValue && lengthB === maxValue) { |
| 162 | return a.localeCompare(b) |
| 163 | } else if (lengthA === maxValue) { |
| 164 | return 1 |
| 165 | } else if (lengthB === maxValue) { |
| 166 | return -1 |
| 167 | } |
| 168 | |
| 169 | if (lengthA > lengthB) { |
| 170 | if (maxA) { |
| 171 | return -1 |
| 172 | } |
| 173 | return 1 |
| 174 | } |
| 175 | |
| 176 | if (lengthA < lengthB) { |
| 177 | if (maxA) { |
| 178 | return 1 |
| 179 | } |
| 180 | return -1 |
| 181 | } |
| 182 | |
| 183 | return a.localeCompare(b) |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 |
no test coverage detected