Fix: Replace jQuery utilities with ES6+ in site templates#680
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restores the “View Source” functionality in the website templates after a jQuery upgrade by replacing removed/deprecated jQuery utility helpers with ES6+ equivalents.
Changes:
- Replaced
$.trim/$.map/$.each/$.extendusage in the view-source templating logic with nativetrim,map,forEach, andObject.assign. - Replaced
$.paramwith manual query-string construction for the AJAX URL. - Updated the refresh template to use native string trimming on the input value.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
site/website/static/js/template.js |
Migrates jQuery utility usage to ES6+ to keep view-source rendering and init wiring working post-upgrade. |
site/website/static/templates/refresh.html |
Removes dependency on $.trim() in the refresh example by using native .trim(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #677 - View source code not working after jQuery upgrade Changes: - Replace $.trim() with String.prototype.trim() - Replace $.map() with Array.prototype.map() - Replace $.each() with Array.prototype.forEach() - Replace $.extend() with Object.assign() - Replace $.param() with URLSearchParams implementation This ensures compatibility with jQuery 4.0+ where utility methods like $.trim() have been removed. Files modified: - site/website/static/js/template.js - site/website/static/templates/refresh.html
fe044b6 to
e246aa7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
site/website/static/js/template.js:172
Object.assign({...}, options_)will throw aTypeErrorifwindow.initis ever called withnullorundefined(whereas the previous$.extendcall tolerated that). Consider defaultingoptions_to an empty object (or conditionally assigning) to keep the initializer resilient.
window.init = function (options_) {
var options = Object.assign({
title: '',
desc: '',
links: [],
scripts: [],
bootstrapVersion: 3,
callback: function () {
if (typeof window.mounted === 'function') {
window.mounted()
}
}
}, options_)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🤔 Type of Request
🔗 Resolves an issue?
Fixes #677 - View source code not working after jQuery upgrade
📝 Description
This PR fixes the broken "View Source" functionality by replacing deprecated jQuery utility methods with ES6+ alternatives in the site templates.
After jQuery was upgraded to the latest version,
$.trim()and other utility methods were removed, causing the view source feature to fail.🎯 Changes
1.
site/website/static/js/template.js$.trim()→String.prototype.trim()$.map()→Array.prototype.map()$.each()→Array.prototype.forEach()$.extend()→Object.assign()$.param()→ Manual URL parameter encoding2.
site/website/static/templates/refresh.html$.trim($input.val())→$input.val().trim()✅ Testing
📊 Files Modified
site/website/static/js/template.js- 8 replacementssite/website/static/templates/refresh.html- 1 replacementLove multiple-select? Please consider supporting us:
👉 https://opencollective.com/multiple-select/donate