fix: check if popover exists after fetching and before inserting
This commit is contained in:
		
							parent
							
								
									275bea3051
								
							
						
					
					
						commit
						d1551872ff
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
					@ -28,8 +28,11 @@ async function mouseEnterHandler(
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const hasAlreadyBeenFetched = () =>
 | 
				
			||||||
 | 
					    [...link.children].some((child) => child.classList.contains("popover"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // dont refetch if there's already a popover
 | 
					  // dont refetch if there's already a popover
 | 
				
			||||||
  if ([...link.children].some((child) => child.classList.contains("popover"))) {
 | 
					  if (hasAlreadyBeenFetched()) {
 | 
				
			||||||
    return setPosition(link.lastChild as HTMLElement)
 | 
					    return setPosition(link.lastChild as HTMLElement)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +52,11 @@ async function mouseEnterHandler(
 | 
				
			||||||
      console.error(err)
 | 
					      console.error(err)
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // bailout if another popover exists
 | 
				
			||||||
 | 
					  if (hasAlreadyBeenFetched()) {
 | 
				
			||||||
 | 
					    return
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!contents) return
 | 
					  if (!contents) return
 | 
				
			||||||
  const html = p.parseFromString(contents, "text/html")
 | 
					  const html = p.parseFromString(contents, "text/html")
 | 
				
			||||||
  normalizeRelativeURLs(html, targetUrl)
 | 
					  normalizeRelativeURLs(html, targetUrl)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue