forked from forgejo/forgejo
Avoid showing unnecessary JS errors when there are elements with different origin on the page (#29081) (#29089)
Backport #29081 by wxiaoguang Try to fix #29080 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> (cherry picked from commit 9a4d283e9ac472dca869356c27db05039673c638)
This commit is contained in:
parent
628e1036cf
commit
614ba2b257
3 changed files with 19 additions and 9 deletions
|
@ -59,6 +59,17 @@ export function onDomReady(cb) {
|
|||
}
|
||||
}
|
||||
|
||||
// checks whether an element is owned by the current document, and whether it is a document fragment or element node
|
||||
// if it is, it means it is a "normal" element managed by us, which can be modified safely.
|
||||
export function isDocumentFragmentOrElementNode(el) {
|
||||
try {
|
||||
return el.ownerDocument === document && el.nodeType === Node.ELEMENT_NODE || el.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
|
||||
} catch {
|
||||
// in case the el is not in the same origin, then the access to nodeType would fail
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// autosize a textarea to fit content. Based on
|
||||
// https://github.com/github/textarea-autosize
|
||||
// ---------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue