mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 19:38:23 +00:00 
			
		
		
		
	Avoid showing unnecessary JS errors when there are elements with different origin on the page (#29081)
Try to fix #29080
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| // for performance considerations, it only uses performant syntax | ||||
| import {isDocumentFragmentOrElementNode} from '../utils/dom.js'; | ||||
|  | ||||
| // for performance considerations, it only uses performant syntax | ||||
| function attachDirAuto(el) { | ||||
|   if (el.type !== 'hidden' && | ||||
|       el.type !== 'checkbox' && | ||||
| @@ -18,7 +19,7 @@ export function initDirAuto() { | ||||
|       const len = mutation.addedNodes.length; | ||||
|       for (let i = 0; i < len; i++) { | ||||
|         const addedNode = mutation.addedNodes[i]; | ||||
|         if (addedNode.nodeType !== Node.ELEMENT_NODE && addedNode.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) continue; | ||||
|         if (!isDocumentFragmentOrElementNode(addedNode)) continue; | ||||
|         if (addedNode.nodeName === 'INPUT' || addedNode.nodeName === 'TEXTAREA') attachDirAuto(addedNode); | ||||
|         const children = addedNode.querySelectorAll('input, textarea'); | ||||
|         const len = children.length; | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| import tippy, {followCursor} from 'tippy.js'; | ||||
| import {isDocumentFragmentOrElementNode} from '../utils/dom.js'; | ||||
|  | ||||
| const visibleInstances = new Set(); | ||||
|  | ||||
| @@ -136,8 +137,6 @@ function attachChildrenLazyTooltip(target) { | ||||
|   } | ||||
| } | ||||
|  | ||||
| const elementNodeTypes = new Set([Node.ELEMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE]); | ||||
|  | ||||
| export function initGlobalTooltips() { | ||||
|   // use MutationObserver to detect new "data-tooltip-content" elements added to the DOM, or attributes changed | ||||
|   const observerConnect = (observer) => observer.observe(document, { | ||||
| @@ -152,11 +151,10 @@ export function initGlobalTooltips() { | ||||
|       if (mutation.type === 'childList') { | ||||
|         // mainly for Vue components and AJAX rendered elements | ||||
|         for (const el of mutation.addedNodes) { | ||||
|           if (elementNodeTypes.has(el.nodeType)) { | ||||
|             attachChildrenLazyTooltip(el); | ||||
|             if (el.hasAttribute('data-tooltip-content')) { | ||||
|               attachLazyTooltip(el); | ||||
|             } | ||||
|           if (!isDocumentFragmentOrElementNode(el)) continue; | ||||
|           attachChildrenLazyTooltip(el); | ||||
|           if (el.hasAttribute('data-tooltip-content')) { | ||||
|             attachLazyTooltip(el); | ||||
|           } | ||||
|         } | ||||
|       } else if (mutation.type === 'attributes') { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user