Update anchor.js

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

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

Loading…
Cancel
Save