diff --git a/src/core/dom.js b/src/core/dom.js index f61c0f617..c0c901bd9 100644 --- a/src/core/dom.js +++ b/src/core/dom.js @@ -102,16 +102,11 @@ const is_visible = (el) => { /** * Test, if a element is a input-type element. * - * This is taken from Sizzle/jQuery at: - * https://github.com/jquery/sizzle/blob/f2a2412e5e8a5d9edf168ae3b6633ac8e6bd9f2e/src/sizzle.js#L139 - * https://github.com/jquery/sizzle/blob/f2a2412e5e8a5d9edf168ae3b6633ac8e6bd9f2e/src/sizzle.js#L1773 - * * @param {Node} el - The DOM node to test. * @returns {Boolean} - True if the element is a input-type element. */ const is_input = (el) => { - const re_input = /^(?:input|select|textarea|button)$/i; - return re_input.test(el.nodeName); + return el.matches("button, input, select, textarea"); }; /** diff --git a/src/core/registry.js b/src/core/registry.js index 03fd0430c..cbd57d5ef 100644 --- a/src/core/registry.js +++ b/src/core/registry.js @@ -133,6 +133,16 @@ 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. @@ -140,6 +150,7 @@ const registry = { 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")) { @@ -180,17 +191,16 @@ const registry = { ); matches = matches.filter((el) => { // Filter out patterns: - // - with class ``.disable-patterns`` - // - wrapped in ``.disable-patterns`` elements + // - with class ``.disable-patterns`` or wrapped within. // - wrapped in ``
`` elements
             // - wrapped in ``