debian-mirror-gitlab/app/assets/javascripts/lib/utils/navigation_utility.js

16 lines
373 B
JavaScript
Raw Normal View History

2018-12-05 23:21:45 +05:30
import { visitUrl } from './url_utility';
2018-10-15 14:42:47 +05:30
2017-08-17 22:00:37 +05:30
/**
* Helper function that finds the href of the fiven selector and updates the location.
*
* @param {String} selector
*/
2018-10-15 14:42:47 +05:30
export default function findAndFollowLink(selector) {
const element = document.querySelector(selector);
const link = element && element.getAttribute('href');
2017-08-17 22:00:37 +05:30
if (link) {
2018-10-15 14:42:47 +05:30
visitUrl(link);
2017-08-17 22:00:37 +05:30
}
2018-10-15 14:42:47 +05:30
}