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

File diff suppressed because one or more lines are too long

View File

@ -15,6 +15,7 @@
<script>
import Downloads from '@/utils/downloads'
import downloadQualities from '@js/qualities'
import { generatePath } from '@/utils/utils'
export default {
data() {
@ -106,7 +107,7 @@ export default {
},
// This computed property is used for rendering the options in the wanted order
// while keeping the options computed property an Object to make the properties
// accessible via property name (es this.options.copy)
// accessible via property name (es this.options.copyLink)
sortedOptions() {
return Object.values(this.options).sort((first, second) => {
return first.position < second.position ? -1 : 1
@ -121,12 +122,9 @@ export default {
showMenu(contextMenuEvent) {
contextMenuEvent.preventDefault()
const {
pageX,
pageY,
path,
path: [elementClicked]
} = contextMenuEvent
const { pageX, pageY, target: elementClicked } = contextMenuEvent
const path = generatePath(elementClicked)
this.positionMenu(pageX, pageY)

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()