removed the usage of the path property of the contextmenu event because apparently it's not standard

This commit is contained in:
Roberto Tonino
2020-08-12 11:55:02 +02:00
parent 6a0966034e
commit 77b202d88e
3 changed files with 25 additions and 8 deletions

View File

@@ -1,3 +1,22 @@
/**
* Climbs the DOM until the root is reached, storing every node passed.
* @param {HTMLElement} el
* @return {Array} Contains all the nodes between el and the root
*/
export function generatePath(el) {
if (!el) {
throw new Error('No element passed to the generatePath function!')
}
let path = [el]
while ((el = el.parentNode) && el !== document) {
path.push(el)
}
return path
}
export function isValidURL(text) {
let lowerCaseText = text.toLowerCase()