DEV: Use native `element.closest()` (#17482)
This commit is contained in:
parent
abe9b41ddf
commit
3ada82f713
|
@ -15,10 +15,10 @@ export default Component.extend({
|
|||
this._clearFlash();
|
||||
}
|
||||
|
||||
let fixedParent = $(this.element).closest(".d-modal.fixed-modal");
|
||||
if (fixedParent.length) {
|
||||
let fixedParent = this.element.closest(".d-modal.fixed-modal");
|
||||
if (fixedParent) {
|
||||
this.set("fixed", true);
|
||||
fixedParent.modal("show");
|
||||
$(fixedParent).modal("show");
|
||||
}
|
||||
|
||||
scheduleOnce("afterRender", this, this._afterFirstRender);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import Component from "@ember/component";
|
||||
|
||||
export default Component.extend({
|
||||
classNameBindings: [":featured-topic"],
|
||||
attributeBindings: ["topic.id:data-topic-id"],
|
||||
|
||||
click(e) {
|
||||
const $target = $(e.target);
|
||||
if ($target.closest(".last-posted-at").length) {
|
||||
if (e.target.closest(".last-posted-at")) {
|
||||
this.appEvents.trigger("topic-entrance:show", {
|
||||
topic: this.topic,
|
||||
position: $target.offset(),
|
||||
position: $(e.target).offset(),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -164,10 +164,10 @@ export default Component.extend(LoadMore, {
|
|||
|
||||
click(e) {
|
||||
const onClick = (sel, callback) => {
|
||||
let target = $(e.target).closest(sel);
|
||||
let target = e.target.closest(sel);
|
||||
|
||||
if (target.length === 1) {
|
||||
callback.apply(this, [target]);
|
||||
if (target) {
|
||||
callback.call(this, target);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -186,8 +186,8 @@ export default Component.extend(LoadMore, {
|
|||
$("input.bulk-select:checked").click();
|
||||
});
|
||||
|
||||
onClick("th.sortable", function (e2) {
|
||||
this.changeSort(e2.data("sort-order"));
|
||||
onClick("th.sortable", function (element) {
|
||||
this.changeSort(element.dataset.sortOrder);
|
||||
this.rerender();
|
||||
});
|
||||
|
||||
|
@ -210,15 +210,15 @@ export default Component.extend(LoadMore, {
|
|||
keyDown(e) {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
let onKeyDown = (sel, callback) => {
|
||||
let target = $(e.target).closest(sel);
|
||||
let target = e.target.closest(sel);
|
||||
|
||||
if (target.length === 1) {
|
||||
callback.apply(this, [target]);
|
||||
if (target) {
|
||||
callback.call(this, target);
|
||||
}
|
||||
};
|
||||
|
||||
onKeyDown("th.sortable", (e2) => {
|
||||
this.changeSort(e2.data("sort-order"));
|
||||
onKeyDown("th.sortable", (element) => {
|
||||
this.changeSort(element.dataset.sortOrder);
|
||||
this.rerender();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -345,11 +345,12 @@ export default Mixin.create({
|
|||
@bind
|
||||
_clickOutsideHandler(event) {
|
||||
if (this.visible) {
|
||||
const $target = $(event.target);
|
||||
if (
|
||||
$target.closest(`[data-${this.elementId}]`).data(this.elementId) ||
|
||||
$target.closest(`a.${this.triggeringLinkClass}`).length > 0 ||
|
||||
$target.closest(`#${this.elementId}`).length > 0
|
||||
event.target
|
||||
.closest(`[data-${this.elementId}]`)
|
||||
?.getAttribute(`data-${this.elementId}`) ||
|
||||
event.target.closest(`a.${this.triggeringLinkClass}`) ||
|
||||
event.target.closest(`#${this.elementId}`)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ export default createWidget("home-logo", {
|
|||
}
|
||||
e.preventDefault();
|
||||
|
||||
DiscourseURL.routeToTag($(e.target).closest("a")[0]);
|
||||
DiscourseURL.routeToTag(e.target.closest("a"));
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -131,6 +131,6 @@ export default createWidget("link", {
|
|||
this.sendWidgetEvent("linkClicked", this.attrs);
|
||||
}
|
||||
|
||||
return DiscourseURL.routeToTag($(e.target).closest("a")[0]);
|
||||
return DiscourseURL.routeToTag(e.target.closest("a"));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -81,7 +81,7 @@ createWidget("topic-admin-menu-button", {
|
|||
if (e === undefined) {
|
||||
$button = $(".keyboard-target-admin-menu");
|
||||
} else {
|
||||
$button = $(e.target).closest("button");
|
||||
$button = $(e.target.closest("button"));
|
||||
}
|
||||
|
||||
const position = $button.position(),
|
||||
|
|
|
@ -70,7 +70,7 @@ createWidget("discourse-poll-option", {
|
|||
},
|
||||
|
||||
click(e) {
|
||||
if ($(e.target).closest("a").length === 0) {
|
||||
if (!e.target.closest("a")) {
|
||||
this.sendWidgetAction("toggleOption", this.attrs.option);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue