mmd.js icon indicating copy to clipboard operation
mmd.js copied to clipboard

String.prototype.link is deprecated

Open davegregg opened this issue 7 years ago • 3 comments

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link

davegregg avatar Jul 22 '18 19:07 davegregg

https://github.com/p01/mmd.js/blob/cd7f4872174bb29ef853f880119909dc70b7b4eb/mmd.js#L13

can change to

.replace(/\[([^\]]+)]\(([^(]+?)\)/g, `<a href="$2">$1</a>`)


I do not send the pull request. I think the author may be more convenient to modify, plus if there are any other slight changes in the future that can also be combined.

CarsonSlovoka avatar Nov 09 '21 06:11 CarsonSlovoka

I am confused about why we need this change.

String.prototype is part of the latest Ecma 262 specification, it is actively supported by all common browser engines, and I have been using it in Node from version 8 to 16.

Does mmd.js fail to generate links for you ? In which environment ?

p01 avatar Dec 30 '21 13:12 p01

ECMA doesn't really deprecate anything. The ES implementations will. So if MDN is highlighting this as deprecated, it is a warning sign. I don't think it is just an MDN editing oversight, as the deprecation is present in Mozilla's browser-compat-data.

Replacing the use of String.prototype.link is both simple and encourages additions to the anchor tag, such as target="_blank" with either rel="noopener" or rel="noreferrer" to alleviate potential security and performance issues.

But you are quite correct to imply that this is in no way urgent.

davegregg avatar Jan 12 '22 18:01 davegregg