DEV: Remove `jQuery` global usage where possible (#14905)
This commit is contained in:
parent
97aa56bdc3
commit
9ca93f57cc
|
@ -5,6 +5,7 @@
|
|||
"eol-last": 2
|
||||
},
|
||||
"globals": {
|
||||
"jQuery": "off",
|
||||
"moduleFor": "off",
|
||||
"moduleForComponent": "off",
|
||||
"testStart": "off",
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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", {
|
||||
|
|
|
@ -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.",
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ const TIMEFRAME_BASE = {
|
|||
};
|
||||
|
||||
function buildTimeframe(opts) {
|
||||
return jQuery.extend({}, TIMEFRAME_BASE, opts);
|
||||
return Object.assign({}, TIMEFRAME_BASE, opts);
|
||||
}
|
||||
|
||||
const TIMEFRAMES = [
|
||||
|
|
|
@ -131,7 +131,7 @@ export default createWidget("button", ButtonClass);
|
|||
|
||||
createWidget(
|
||||
"flat-button",
|
||||
jQuery.extend(ButtonClass, {
|
||||
Object.assign(ButtonClass, {
|
||||
tagName: "button.widget-button.btn-flat",
|
||||
})
|
||||
);
|
||||
|
|
|
@ -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",
|
||||
|
||||
|
|
|
@ -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", {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue