DEV: Remove `jQuery` global usage where possible (#14905)

This commit is contained in:
Jarek Radosz 2021-11-12 19:23:20 +01:00 committed by GitHub
parent 97aa56bdc3
commit 9ca93f57cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 16 additions and 8 deletions

View File

@ -5,6 +5,7 @@
"eol-last": 2
},
"globals": {
"jQuery": "off",
"moduleFor": "off",
"moduleForComponent": "off",
"testStart": "off",

View File

@ -18,7 +18,7 @@ function lookupView(templateName) {
}
function renderRaw(ctx, template, templateName, params) {
params = jQuery.extend({}, params);
params = Object.assign({}, params);
params.parent = params.parent || ctx;
let context = helperContext();
@ -30,7 +30,7 @@ function renderRaw(ctx, template, templateName, params) {
}
if (!params.view) {
params = jQuery.extend({}, params, context);
params = Object.assign({}, params, context);
}
}

View File

@ -50,6 +50,7 @@ export function longDateNoYear(dt) {
}
export function updateRelativeAge(elems) {
// eslint-disable-next-line no-undef
if (elems instanceof jQuery) {
elems = elems.toArray();
deprecated("updateRelativeAge now expects a DOM NodeList", {

View File

@ -14,6 +14,7 @@ export default function highlightSyntax(elem, siteSettings, session) {
: "pre code[class]";
const path = session.highlightJsPath;
// eslint-disable-next-line no-undef
if (elem instanceof jQuery) {
deprecated(
"highlightSyntax now takes a DOM node instead of a jQuery object.",

View File

@ -8,6 +8,7 @@ const tagHashtags = {};
const checkedHashtags = new Set();
export function linkSeenHashtags(elem) {
// eslint-disable-next-line no-undef
if (elem instanceof jQuery) {
elem = elem[0];

View File

@ -67,6 +67,7 @@ function updateFound(mentions, usernames) {
}
export function linkSeenMentions(elem, siteSettings) {
// eslint-disable-next-line no-undef
if (elem instanceof jQuery) {
elem = elem[0];

View File

@ -53,7 +53,7 @@ function findClass(outletName, uniqueName) {
let foundClass = _extraConnectorClasses[id] || _classPaths[id];
return foundClass
? jQuery.extend({}, DefaultConnectorClass, foundClass)
? Object.assign({}, DefaultConnectorClass, foundClass)
: DefaultConnectorClass;
}

View File

@ -6,7 +6,7 @@ const TIMEFRAME_BASE = {
};
function buildTimeframe(opts) {
return jQuery.extend({}, TIMEFRAME_BASE, opts);
return Object.assign({}, TIMEFRAME_BASE, opts);
}
const TIMEFRAMES = [

View File

@ -131,7 +131,7 @@ export default createWidget("button", ButtonClass);
createWidget(
"flat-button",
jQuery.extend(ButtonClass, {
Object.assign(ButtonClass, {
tagName: "button.widget-button.btn-flat",
})
);

View File

@ -146,7 +146,7 @@ createWidget("header-notifications", {
createWidget(
"user-dropdown",
jQuery.extend(
Object.assign(
{
tagName: "li.header-dropdown-toggle.current-user",
@ -176,7 +176,7 @@ createWidget(
createWidget(
"header-dropdown",
jQuery.extend(
Object.assign(
{
tagName: "li.header-dropdown-toggle",

View File

@ -4,7 +4,7 @@ import { h } from "virtual-dom";
createWidget(
"post-admin-menu-button",
jQuery.extend(ButtonClass, { tagName: "li.btn" })
Object.assign(ButtonClass, { tagName: "li.btn" })
);
createWidget("post-admin-menu-button", {

View File

@ -65,6 +65,7 @@ async function keyboardHelper(value, target, selector) {
if (value === "selectAll") {
// special casing the only one not working with triggerEvent
// eslint-disable-next-line no-undef
const event = jQuery.Event("keydown");
event.key = "A";
event.keyCode = 65;

View File

@ -379,6 +379,7 @@ function setupTestsCommon(application, container, config) {
}
// forces 0 as duration for all jquery animations
// eslint-disable-next-line no-undef
jQuery.fx.off = true;
setupToolbar();

View File

@ -5,6 +5,7 @@ import getUrl from "discourse-common/lib/get-url";
import { htmlSafe } from "@ember/template";
import { schedule } from "@ember/runloop";
// eslint-disable-next-line no-undef
jQuery.fn.wiggle = function (times, duration) {
if (times > 0) {
this.animate(