Skip to content

Commit 369c7b5

Browse files
authored
Ensure resorted plugins take into account all plugins they need to sort relative to (tailwindlabs#4852)
1 parent b417e33 commit 369c7b5

File tree

5 files changed

+659
-630
lines changed

5 files changed

+659
-630
lines changed

src/corePlugins.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import * as plugins from './plugins/index.js'
22
import configurePlugins from './util/configurePlugins'
33

4-
function move(items, item, before) {
5-
if (items.indexOf(item) === -1) {
4+
function move(items, item, befores) {
5+
let lowestBefore = -1
6+
7+
for (let before of befores) {
8+
let index = items.indexOf(before)
9+
if (index >= 0 && (index < lowestBefore || lowestBefore === -1)) {
10+
lowestBefore = index
11+
}
12+
}
13+
14+
if (items.indexOf(item) === -1 || lowestBefore === -1) {
615
return items
716
}
817

918
items = [...items]
1019
let fromIndex = items.indexOf(item)
11-
let toIndex = items.indexOf(before)
20+
let toIndex = lowestBefore
1221
items.splice(fromIndex, 1)
1322
items.splice(toIndex, 0, item)
1423
return items
@@ -18,9 +27,29 @@ export default function ({ corePlugins: corePluginConfig }) {
1827
let pluginOrder = Object.keys(plugins)
1928

2029
pluginOrder = configurePlugins(corePluginConfig, pluginOrder)
21-
pluginOrder = move(pluginOrder, 'transform', 'transformOrigin')
22-
pluginOrder = move(pluginOrder, 'filter', 'blur')
23-
pluginOrder = move(pluginOrder, 'backdropFilter', 'backdropBlur')
30+
pluginOrder = move(pluginOrder, 'transform', ['translate', 'rotate', 'skew', 'scale'])
31+
pluginOrder = move(pluginOrder, 'filter', [
32+
'blur',
33+
'brightness',
34+
'contrast',
35+
'dropShadow',
36+
'grayscale',
37+
'hueRotate',
38+
'invert',
39+
'saturate',
40+
'sepia',
41+
])
42+
pluginOrder = move(pluginOrder, 'backdropFilter', [
43+
'backdropBlur',
44+
'backdropBrightness',
45+
'backdropContrast',
46+
'backdropGrayscale',
47+
'backdropHueRotate',
48+
'backdropInvert',
49+
'backdropOpacity',
50+
'backdropSaturate',
51+
'backdropSepia',
52+
])
2453

2554
return pluginOrder.map((pluginName) => {
2655
return plugins[pluginName]()

0 commit comments

Comments
 (0)