Skip to content

Commit

Permalink
Fix: Uncaught DOMException
Browse files Browse the repository at this point in the history
  • Loading branch information
AnYiEE committed Dec 1, 2023
1 parent 0a51868 commit 2481d16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion static/wikimirror.js

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions static/wikimirror.tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@
return;
}
const surroundTexts = (node, emoji) => {
const {parentNode, nodeValue: _nodeValue} = node;
if (!_nodeValue || !parentNode) {
const {nodeName, parentNode, nodeValue: _nodeValue} = node;
if (nodeName === '#comment' || !_nodeValue || !parentNode) {
return;
}
const startIndex = _nodeValue.indexOf(emoji);
Expand Down Expand Up @@ -1676,18 +1676,16 @@
}
return _preNotification;
};
if ('IntersectionObserver' in window) {
const observerCallback = async (entries) => {
const [entry] = entries;
if (!entry) {
return;
}
const {intersectionRatio} = entry;
preNotification = await toggleToc(intersectionRatio === 0, preNotification);
};
const intersectionObserver = new IntersectionObserver(observerCallback);
intersectionObserver.observe(originToc);
}
const observerCallback = async (entries) => {
const [entry] = entries;
if (!entry) {
return;
}
const {intersectionRatio} = entry;
preNotification = await toggleToc(intersectionRatio === 0, preNotification);
};
const intersectionObserver = new IntersectionObserver(observerCallback);
intersectionObserver.observe(originToc);
const $originTocItem = jQuery(originToc).find('a');
$originTocItem.on('click', smoothScroll);
$originTocItem.on('keydown', smoothScroll);
Expand Down

0 comments on commit 2481d16

Please sign in to comment.