Commit 861db903 authored by Scott Hampton's avatar Scott Hampton

Merge branch 'move-to-jquery-slim' into 'master'

Move to jquery slim [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!41901
parents 78417a45 085d8b4c
...@@ -47,7 +47,7 @@ export default class FileTemplateSelector { ...@@ -47,7 +47,7 @@ export default class FileTemplateSelector {
} }
isHidden() { isHidden() {
return this.$wrapper.hasClass('hidden'); return !this.$wrapper || this.$wrapper.hasClass('hidden');
} }
getToggleText() { getToggleText() {
......
...@@ -82,7 +82,7 @@ export default class EditBlob { ...@@ -82,7 +82,7 @@ export default class EditBlob {
this.$editModePanes.hide(); this.$editModePanes.hide();
currentPane.fadeIn(200); currentPane.show();
if (paneId === '#preview') { if (paneId === '#preview') {
this.$toggleButton.hide(); this.$toggleButton.hide();
......
...@@ -16,21 +16,16 @@ import { initRails } from '~/lib/utils/rails_ujs'; ...@@ -16,21 +16,16 @@ import { initRails } from '~/lib/utils/rails_ujs';
import * as popovers from '~/popovers'; import * as popovers from '~/popovers';
import * as tooltips from '~/tooltips'; import * as tooltips from '~/tooltips';
import initAlertHandler from './alert_handler'; import initAlertHandler from './alert_handler';
import { deprecatedCreateFlash as Flash, removeFlashClickListener } from './flash'; import { removeFlashClickListener } from './flash';
import initTodoToggle from './header'; import initTodoToggle from './header';
import initLayoutNav from './layout_nav'; import initLayoutNav from './layout_nav';
import { import { handleLocationHash, addSelectOnFocusBehaviour } from './lib/utils/common_utils';
handleLocationHash,
addSelectOnFocusBehaviour,
getCspNonceValue,
} from './lib/utils/common_utils';
import { localTimeAgo } from './lib/utils/datetime_utility'; import { localTimeAgo } from './lib/utils/datetime_utility';
import { getLocationHash, visitUrl } from './lib/utils/url_utility'; import { getLocationHash, visitUrl } from './lib/utils/url_utility';
// everything else // everything else
import initFeatureHighlight from './feature_highlight'; import initFeatureHighlight from './feature_highlight';
import LazyLoader from './lazy_loader'; import LazyLoader from './lazy_loader';
import { __ } from './locale';
import initLogoAnimation from './logo'; import initLogoAnimation from './logo';
import initFrequentItemDropdowns from './frequent_items'; import initFrequentItemDropdowns from './frequent_items';
import initBreadcrumbs from './breadcrumb'; import initBreadcrumbs from './breadcrumb';
...@@ -49,29 +44,8 @@ applyGitLabUIConfig(); ...@@ -49,29 +44,8 @@ applyGitLabUIConfig();
window.jQuery = jQuery; window.jQuery = jQuery;
window.$ = jQuery; window.$ = jQuery;
// Add nonce to jQuery script handler
jQuery.ajaxSetup({
converters: {
// eslint-disable-next-line @gitlab/require-i18n-strings, func-names
'text script': function (text) {
jQuery.globalEval(text, { nonce: getCspNonceValue() });
return text;
},
},
});
function disableJQueryAnimations() {
$.fx.off = true;
}
// Disable jQuery animations
if (gon?.disable_animations) {
disableJQueryAnimations();
}
// inject test utilities if necessary // inject test utilities if necessary
if (process.env.NODE_ENV !== 'production' && gon?.test_env) { if (process.env.NODE_ENV !== 'production' && gon?.test_env) {
disableJQueryAnimations();
import(/* webpackMode: "eager" */ './test_utils/'); import(/* webpackMode: "eager" */ './test_utils/');
} }
...@@ -239,17 +213,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -239,17 +213,6 @@ document.addEventListener('DOMContentLoaded', () => {
} }
}); });
// eslint-disable-next-line no-jquery/no-ajax-events
$(document).ajaxError((e, xhrObj) => {
const ref = xhrObj.status;
if (ref === 401) {
Flash(__('You need to be logged in.'));
} else if (ref === 404 || ref === 500) {
Flash(__('Something went wrong on our end.'));
}
});
$('.navbar-toggler').on('click', () => { $('.navbar-toggler').on('click', () => {
$('.header-content').toggleClass('menu-expanded'); $('.header-content').toggleClass('menu-expanded');
}); });
......
...@@ -121,6 +121,7 @@ const alias = { ...@@ -121,6 +121,7 @@ const alias = {
images: path.join(ROOT_PATH, 'app/assets/images'), images: path.join(ROOT_PATH, 'app/assets/images'),
vendor: path.join(ROOT_PATH, 'vendor/assets/javascripts'), vendor: path.join(ROOT_PATH, 'vendor/assets/javascripts'),
vue$: 'vue/dist/vue.esm.js', vue$: 'vue/dist/vue.esm.js',
jquery$: 'jquery/dist/jquery.slim.js',
spec: path.join(ROOT_PATH, 'spec/javascripts'), spec: path.join(ROOT_PATH, 'spec/javascripts'),
jest: path.join(ROOT_PATH, 'spec/frontend'), jest: path.join(ROOT_PATH, 'spec/frontend'),
shared_queries: path.join(ROOT_PATH, 'app/graphql/queries'), shared_queries: path.join(ROOT_PATH, 'app/graphql/queries'),
......
...@@ -13,6 +13,9 @@ module.exports = { ...@@ -13,6 +13,9 @@ module.exports = {
mode: 'development', mode: 'development',
resolve: { resolve: {
extensions: ['.js'], extensions: ['.js'],
alias: {
jquery$: 'jquery/dist/jquery.slim.js',
},
}, },
// ensure output is not generated when errors are encountered // ensure output is not generated when errors are encountered
...@@ -22,7 +25,7 @@ module.exports = { ...@@ -22,7 +25,7 @@ module.exports = {
entry: { entry: {
vendor: [ vendor: [
'jquery', 'jquery/dist/jquery.slim.js',
'pdfjs-dist/build/pdf', 'pdfjs-dist/build/pdf',
'pdfjs-dist/build/pdf.worker.min', 'pdfjs-dist/build/pdf.worker.min',
'sql.js', 'sql.js',
......
...@@ -50,6 +50,7 @@ module.exports = (path, options = {}) => { ...@@ -50,6 +50,7 @@ module.exports = (path, options = {}) => {
'emojis(/.*).json': '<rootDir>/fixtures/emojis$1.json', 'emojis(/.*).json': '<rootDir>/fixtures/emojis$1.json',
'^spec/test_constants$': '<rootDir>/spec/frontend/__helpers__/test_constants', '^spec/test_constants$': '<rootDir>/spec/frontend/__helpers__/test_constants',
'^jest/(.*)$': '<rootDir>/spec/frontend/$1', '^jest/(.*)$': '<rootDir>/spec/frontend/$1',
'^jquery$': '<rootDir>/node_modules/jquery/dist/jquery.slim.js',
...extModuleNameMapper, ...extModuleNameMapper,
}; };
......
...@@ -34919,9 +34919,6 @@ msgstr "" ...@@ -34919,9 +34919,6 @@ msgstr ""
msgid "You need permission." msgid "You need permission."
msgstr "" msgstr ""
msgid "You need to be logged in."
msgstr ""
msgid "You need to register a two-factor authentication app before you can set up a device." msgid "You need to register a two-factor authentication app before you can set up a device."
msgstr "" msgstr ""
......
...@@ -33,7 +33,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ...@@ -33,7 +33,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(function (root, factory) { (function (root, factory) {
if (typeof module !== 'undefined' && module.exports) { if (typeof module !== 'undefined' && module.exports) {
factory(root, root.jasmine, require('jquery')); // The line below is patched from jquery => jquery/dist/jquery
// in order to load a jQuery with ajax, so that this testing library
// doesn't break
factory(root, root.jasmine, require('jquery/dist/jquery'));
} else { } else {
factory(root, root.jasmine, root.jQuery); factory(root, root.jasmine, root.jQuery);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment