open html links in a new tab
This commit is contained in:
parent
d03198c851
commit
221cf8519a
1 changed files with 14 additions and 0 deletions
|
|
@ -1,5 +1,19 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
|
||||||
|
// set all elements owning target to target=_blank
|
||||||
|
if ('target' in node) {
|
||||||
|
node.setAttribute('target', '_blank');
|
||||||
|
}
|
||||||
|
// set non-HTML/MathML links to xlink:show=new
|
||||||
|
if (
|
||||||
|
!node.hasAttribute('target') &&
|
||||||
|
(node.hasAttribute('xlink:href') || node.hasAttribute('href'))
|
||||||
|
) {
|
||||||
|
node.setAttribute('xlink:show', 'new');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Vue.prototype.$sanitize = DOMPurify.sanitize
|
Vue.prototype.$sanitize = DOMPurify.sanitize
|
||||||
|
|
||||||
var debounce = function(callback, wait) {
|
var debounce = function(callback, wait) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue