Update anchor.js

pull/552/head
Anton 2 years ago committed by GitHub
parent 2199ba4648
commit 908306c271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -45,32 +45,28 @@ jQuery.fn.dataTable.render.anchor = function (
innerText = data;
}
if (attributes typeof 'function') {
var tagAttributes = attributes(data, row, meta);
} else {
var tagAttributes = attributes;
}
var attributes = attributes typeof 'function' ? attributes(data, row, meta) : attributes;
if (!tagAttributes.href) {
if (!attributes.href) {
switch (type) {
case 'mail':
tagAttributes.href = 'mailto:' + data;
attributes.href = 'mailto:' + data;
break;
case 'phone':
tagAttributes.href = 'tel:' + data.replace(/[^+\d]+/g, '');
attributes.href = 'tel:' + data.replace(/[^+\d]+/g, '');
break;
case 'link':
case default:
try {
tagAttributes.href = new URL(data);
attributes.href = new URL(data);
} catch (e) {
tagAttributes.href = data;
attributes.href = data;
}
}
}
var anchorEl = jQuery('</a>');
anchorEl.attr(tagAttributes).text(innerText === null ? data : innerText);
anchorEl.attr(attributes).text(innerText);
return anchorEl[0].outerText;
};

Loading…
Cancel
Save