Skip to content

Commit 5a791f7

Browse files
TCOTCwwb0123
authored andcommitted
Replace the deprecated isSameNode method in DOM Level 4 with the === operator (siyuan-note#15347)
1 parent 718f989 commit 5a791f7

51 files changed

Lines changed: 160 additions & 160 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/ai/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
255255
});
256256
element.addEventListener("click", (event) => {
257257
let target = event.target as HTMLElement;
258-
while (target && !target.isSameNode(element)) {
258+
while (target && (target !== element)) {
259259
if (target.classList.contains("b3-list-item__action")) {
260260
const subItem = window.siyuan.storage[Constants.LOCAL_AI][target.parentElement.dataset.index];
261261
editDialog(subItem.name, subItem.memo);

app/src/block/popover.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const initBlockPopover = (app: App) => {
117117
const boxData = response.data.boxInfo;
118118
const tip = `${boxData.name} <small class='ft__on-surface'>${boxData.hSize}</small>${boxData.docCount !== 0 ? window.siyuan.languages.includeSubFile.replace("x", boxData.docCount) : ""}<br>${window.siyuan.languages.modifiedAt} ${boxData.hMtime}<br>${window.siyuan.languages.createdAt} ${boxData.hCtime}`;
119119
const scopeNotebookItemElement = hasClosestByClassName(event.target, "b3-list-item__text");
120-
if (notebookItemElement && scopeNotebookItemElement && notebookItemElement.isSameNode(scopeNotebookItemElement)) {
120+
if (notebookItemElement && scopeNotebookItemElement && (notebookItemElement === scopeNotebookItemElement)) {
121121
showTooltip(tip, notebookItemElement);
122122
}
123123
if (scopeNotebookItemElement &&
@@ -242,7 +242,7 @@ const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => {
242242
if (!popoverTargetElement && linkElement && linkElement.getAttribute("data-href")?.startsWith("siyuan://blocks")) {
243243
popoverTargetElement = linkElement;
244244
}
245-
if (!popoverTargetElement || (popoverTargetElement && window.siyuan.menus.menu.data?.isSameNode(popoverTargetElement))) {
245+
if (!popoverTargetElement || (popoverTargetElement && window.siyuan.menus.menu.data && (window.siyuan.menus.menu.data === popoverTargetElement))) {
246246
// 移动到弹窗的 loading 元素上,但经过 settimeout 后 loading 已经被移除了
247247
// https://ld246.com/article/1673596577519/comment/1673767749885#comments
248248
let targetElement = target;
@@ -356,7 +356,7 @@ const getTarget = (event: MouseEvent & { target: HTMLElement }, aElement: false
356356
};
357357

358358
export const showPopover = async (app: App, showRef = false) => {
359-
if (!popoverTargetElement || window.siyuan.menus.menu.data?.isSameNode(popoverTargetElement)) {
359+
if (!popoverTargetElement || (window.siyuan.menus.menu.data && (window.siyuan.menus.menu.data === popoverTargetElement))) {
360360
return;
361361
}
362362
let refDefs: IRefDefs[] = [];

app/src/boot/globalEvent/keydown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import {bindAVPanelKeydown} from "../../protyle/render/av/keydown";
8080
const switchDialogEvent = (app: App, event: MouseEvent) => {
8181
event.preventDefault();
8282
let target = event.target as HTMLElement;
83-
while (!target.isSameNode(switchDialog.element)) {
83+
while (target !== switchDialog.element) {
8484
if (target.classList.contains("b3-list-item")) {
8585
const currentType = target.getAttribute("data-type");
8686
if (currentType) {

app/src/boot/globalEvent/mousemove.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const windowMouseMove = (event: MouseEvent, mouseIsEnter: boolean) => {
111111
const allModels = getAllModels();
112112
let findNode = false;
113113
allModels.editor.find(item => {
114-
if (item.editor.protyle.wysiwyg.element.isSameNode(eventPath0)) {
114+
if (item.editor.protyle.wysiwyg.element === eventPath0) {
115115
item.editor.protyle.gutter.render(item.editor.protyle, targetBlockElement, item.editor.protyle.wysiwyg.element, rowElement);
116116
findNode = true;
117117
return true;
@@ -134,7 +134,7 @@ export const windowMouseMove = (event: MouseEvent, mouseIsEnter: boolean) => {
134134
if (!findNode) {
135135
allModels.backlink.find(item => {
136136
item.editors.find(eItem => {
137-
if (eItem.protyle.wysiwyg.element.isSameNode(eventPath0)) {
137+
if (eItem.protyle.wysiwyg.element === eventPath0) {
138138
eItem.protyle.gutter.render(eItem.protyle, targetBlockElement, eItem.protyle.wysiwyg.element, rowElement);
139139
findNode = true;
140140
return true;

app/src/card/makeCard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const makeCard = (app: App, ids: string[]) => {
7171
dialog.element.setAttribute("data-key", Constants.DIALOG_MAKECARD);
7272
dialog.element.addEventListener("click", (event) => {
7373
let target = event.target as HTMLElement;
74-
while (target && !target.isSameNode(dialog.element)) {
74+
while (target && (target !== dialog.element)) {
7575
const type = target.getAttribute("data-type");
7676
if (type === "create") {
7777
let msgId = "";

app/src/card/viewCards.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
115115
return;
116116
}
117117
let target = event.target as HTMLElement;
118-
while (target && !dialog.element.isSameNode(target)) {
118+
while (target && (dialog.element !== target)) {
119119
const type = target.getAttribute("data-type");
120120
if (type === "close") {
121121
dialog.destroy();

app/src/config/keymap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export const keymap = {
475475
hasConflict = true;
476476
}
477477
Array.from(keymap.element.querySelectorAll("label.b3-list-item input")).find((inputItem: HTMLElement) => {
478-
if (!inputItem.isSameNode(this) && inputItem.getAttribute("data-value") === keymapStr) {
478+
if ((inputItem !== this) && inputItem.getAttribute("data-value") === keymapStr) {
479479
const inputValueList = inputItem.getAttribute("data-key").split(Constants.ZWSP);
480480
if (inputValueList[1] === "list") {
481481
inputValueList[1] = "list1";

app/src/config/util/snippets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const openSnippets = () => {
114114
dialog.element.setAttribute("data-key", Constants.DIALOG_SNIPPETS);
115115
dialog.element.addEventListener("click", (event) => {
116116
let target = event.target as HTMLElement;
117-
while (target && !target.isSameNode(dialog.element)) {
117+
while (target && (target !== dialog.element)) {
118118
if (target.id === "addCodeSnippetCSS" || target.id === "addCodeSnippetJS") {
119119
target.parentElement.insertAdjacentHTML("afterend", genSnippet({
120120
type: target.id === "addCodeSnippetCSS" ? "css" : "js",

app/src/dialog/confirmDialog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const confirmDialog = (title: string, text: string,
2525
dialog.element.addEventListener("click", (event) => {
2626
let target = event.target as HTMLElement;
2727
const isDispatch = typeof event.detail === "string";
28-
while (target && !target.isSameNode(dialog.element) || isDispatch) {
28+
while (target && (target !== dialog.element) || isDispatch) {
2929
if (target.id === "cancelDialogConfirmBtn" || (isDispatch && event.detail=== "Escape")) {
3030
if (cancel) {
3131
cancel(dialog);

app/src/dialog/message.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const initMessage = () => {
1212
hideMessage(target.parentElement.getAttribute("data-id"));
1313
event.preventDefault();
1414
break;
15-
} else if (target.isSameNode(messageElement.lastElementChild)) {
15+
} else if (target === messageElement.lastElementChild) {
1616
target.parentElement.classList.remove("b3-snackbars--show");
1717
setTimeout(() => {
1818
target.parentElement.firstElementChild.innerHTML = "";

0 commit comments

Comments
 (0)