Right now, the behavior of links to open a new tab is attached individually every time a link is generated.
This is fragile. For example, #217 introduced a regression where toggling the URL-to-link setting would strip the event from all affected links. Then #261 made it worse by triggering the change event on the setting every time ui.loadSettings() is called - even if the settings haven't actually changed, eg. when the local settings are uploaded to the server.
There are clearly at least two other bugs in here - firstly, don't alter the markup unless it needs to be altered, secondly, don't call loadSettings() unless the settings need to be loaded - but clearly, having to reattach the event every time markup is generated is a really bad idea.
Put it on the document handler with a descendant selector instead.
Right now, the behavior of links to open a new tab is attached individually every time a link is generated.
This is fragile. For example, #217 introduced a regression where toggling the URL-to-link setting would strip the event from all affected links. Then #261 made it worse by triggering the change event on the setting every time ui.loadSettings() is called - even if the settings haven't actually changed, eg. when the local settings are uploaded to the server.
There are clearly at least two other bugs in here - firstly, don't alter the markup unless it needs to be altered, secondly, don't call loadSettings() unless the settings need to be loaded - but clearly, having to reattach the event every time markup is generated is a really bad idea.
Put it on the document handler with a descendant selector instead.