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 {
}
isHidden() {
return this.$wrapper.hasClass('hidden');
return !this.$wrapper || this.$wrapper.hasClass('hidden');
}
getToggleText() {
......
......@@ -82,7 +82,7 @@ export default class EditBlob {
this.$editModePanes.hide();
currentPane.fadeIn(200);
currentPane.show();
if (paneId === '#preview') {
this.$toggleButton.hide();
......
......@@ -16,21 +16,16 @@ import { initRails } from '~/lib/utils/rails_ujs';
import * as popovers from '~/popovers';
import * as tooltips from '~/tooltips';
import initAlertHandler from './alert_handler';
import { deprecatedCreateFlash as Flash, removeFlashClickListener } from './flash';
import { removeFlashClickListener } from './flash';
import initTodoToggle from './header';
import initLayoutNav from './layout_nav';
import {
handleLocationHash,
addSelectOnFocusBehaviour,
getCspNonceValue,
} from './lib/utils/common_utils';
import { handleLocationHash, addSelectOnFocusBehaviour } from './lib/utils/common_utils';
import { localTimeAgo } from './lib/utils/datetime_utility';
import { getLocationHash, visitUrl } from './lib/utils/url_utility';
// everything else
import initFeatureHighlight from './feature_highlight';
import LazyLoader from './lazy_loader';
import { __ } from './locale';
import initLogoAnimation from './logo';
import initFrequentItemDropdowns from './frequent_items';
import initBreadcrumbs from './breadcrumb';
......@@ -49,29 +44,8 @@ applyGitLabUIConfig();
window.jQuery = 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
if (process.env.NODE_ENV !== 'production' && gon?.test_env) {
disableJQueryAnimations();
import(/* webpackMode: "eager" */ './test_utils/');
}
......@@ -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', () => {
$('.header-content').toggleClass('menu-expanded');
});
......
......@@ -121,6 +121,7 @@ const alias = {
images: path.join(ROOT_PATH, 'app/assets/images'),
vendor: path.join(ROOT_PATH, 'vendor/assets/javascripts'),
vue$: 'vue/dist/vue.esm.js',
jquery$: 'jquery/dist/jquery.slim.js',
spec: path.join(ROOT_PATH, 'spec/javascripts'),
jest: path.join(ROOT_PATH, 'spec/frontend'),
shared_queries: path.join(ROOT_PATH, 'app/graphql/queries'),
......
......@@ -13,6 +13,9 @@ module.exports = {
mode: 'development',
resolve: {
extensions: ['.js'],
alias: {
jquery$: 'jquery/dist/jquery.slim.js',
},
},
// ensure output is not generated when errors are encountered
......@@ -22,7 +25,7 @@ module.exports = {
entry: {
vendor: [
'jquery',
'jquery/dist/jquery.slim.js',
'pdfjs-dist/build/pdf',
'pdfjs-dist/build/pdf.worker.min',
'sql.js',
......
......@@ -50,6 +50,7 @@ module.exports = (path, options = {}) => {
'emojis(/.*).json': '<rootDir>/fixtures/emojis$1.json',
'^spec/test_constants$': '<rootDir>/spec/frontend/__helpers__/test_constants',
'^jest/(.*)$': '<rootDir>/spec/frontend/$1',
'^jquery$': '<rootDir>/node_modules/jquery/dist/jquery.slim.js',
...extModuleNameMapper,
};
......
......@@ -34919,9 +34919,6 @@ msgstr ""
msgid "You need permission."
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."
msgstr ""
......
......@@ -33,7 +33,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(function (root, factory) {
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 {
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