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> <script>
import Downloads from '@/utils/downloads' import Downloads from '@/utils/downloads'
import downloadQualities from '@js/qualities' import downloadQualities from '@js/qualities'
import { generatePath } from '@/utils/utils'
export default { export default {
data() { data() {
@ -106,7 +107,7 @@ export default {
}, },
// This computed property is used for rendering the options in the wanted order // 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 // 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() { sortedOptions() {
return Object.values(this.options).sort((first, second) => { return Object.values(this.options).sort((first, second) => {
return first.position < second.position ? -1 : 1 return first.position < second.position ? -1 : 1
@ -121,12 +122,9 @@ export default {
showMenu(contextMenuEvent) { showMenu(contextMenuEvent) {
contextMenuEvent.preventDefault() contextMenuEvent.preventDefault()
const { const { pageX, pageY, target: elementClicked } = contextMenuEvent
pageX,
pageY, const path = generatePath(elementClicked)
path,
path: [elementClicked]
} = contextMenuEvent
this.positionMenu(pageX, pageY) 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) { export function isValidURL(text) {
let lowerCaseText = text.toLowerCase() let lowerCaseText = text.toLowerCase()