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

Loading…
Cancel
Save