Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Their was a change to add a regex tag utility function in #2024 and this combined three regex creations into a single function. Since then it seems the svg and title regex were simplified out with the htmx 2.0 re-write and we are now left with a redundant function that is only used to generate a single HEAD_TAG_REGEX which is only used once in makeFragment. So my proposed change here is to just simply remove this utility function and move the single use regex inline which should simplify readability and code minification.
Previous regex format was:
And I'm simplified this to:
/<head(\s[^>]*)?>.*?<\/head>/is
Note [\s\S] is now .* because of the s option and m option is not needed here.
Corresponding issue:
Testing
Found the manual tests added with the #2024 change and was able to manually test this change worked fine with these manual tests after updating the test to link to the now external head-support extension.
Also tested with
npm run test
but found that this remove head feature in makeFragment has no coverage in these tests as breaking it caused no test failures. Because it is only used by head-support extension and not core htmx.Manually ran the manual-tests folder in the head-support extension with the updated htmx changes as well and found no issues.
Checklist
master
for website changes,dev
forsource changes)
approved via an issue
npm run test
) and verified that it succeeded