Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure resorted plugins take into account all plugins they need to sort relative to #4852

Merged
merged 1 commit into from Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 35 additions & 6 deletions src/corePlugins.js
@@ -1,14 +1,23 @@
import * as plugins from './plugins/index.js'
import configurePlugins from './util/configurePlugins'

function move(items, item, before) {
if (items.indexOf(item) === -1) {
function move(items, item, befores) {
let lowestBefore = -1

for (let before of befores) {
let index = items.indexOf(before)
if (index >= 0 && (index < lowestBefore || lowestBefore === -1)) {
lowestBefore = index
}
}

if (items.indexOf(item) === -1 || lowestBefore === -1) {
return items
}

items = [...items]
let fromIndex = items.indexOf(item)
let toIndex = items.indexOf(before)
let toIndex = lowestBefore
items.splice(fromIndex, 1)
items.splice(toIndex, 0, item)
return items
Expand All @@ -18,9 +27,29 @@ export default function ({ corePlugins: corePluginConfig }) {
let pluginOrder = Object.keys(plugins)

pluginOrder = configurePlugins(corePluginConfig, pluginOrder)
pluginOrder = move(pluginOrder, 'transform', 'transformOrigin')
pluginOrder = move(pluginOrder, 'filter', 'blur')
pluginOrder = move(pluginOrder, 'backdropFilter', 'backdropBlur')
pluginOrder = move(pluginOrder, 'transform', ['translate', 'rotate', 'skew', 'scale'])
pluginOrder = move(pluginOrder, 'filter', [
'blur',
'brightness',
'contrast',
'dropShadow',
'grayscale',
'hueRotate',
'invert',
'saturate',
'sepia',
])
pluginOrder = move(pluginOrder, 'backdropFilter', [
'backdropBlur',
'backdropBrightness',
'backdropContrast',
'backdropGrayscale',
'backdropHueRotate',
'backdropInvert',
'backdropOpacity',
'backdropSaturate',
'backdropSepia',
])

return pluginOrder.map((pluginName) => {
return plugins[pluginName]()
Expand Down