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

DRAFT: feat(core registry): Implement sort_early Pattern option. #1225

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/core/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,24 @@ const registry = {
},

orderPatterns(patterns) {
// Resort patterns and set those with `sort_early` to the beginning.
// NOTE: Only use when necessary and it's not guaranteed that a pattern
// with `sort_early` is set to the beginning. Last come, first serve.
for (const name of [...patterns]) {
if (registry[name]?.sort_early) {
patterns.splice(patterns.indexOf(name), 1);
patterns.unshift(name);
}
}

// Always add pat-validation as first pattern, so that it can prevent
// other patterns from reacting to submit events if form validation
// fails.
if (patterns.includes("validation")) {
patterns.splice(patterns.indexOf("validation"), 1);
patterns.unshift("validation");
}

// Add clone-code to the very beginning - we want to copy the markup
// before any other patterns changed the markup.
if (patterns.includes("clone-code")) {
Expand Down
Loading