tinycon
tinycon copied to clipboard
convert htmlcollection to simple array
(sorry bad english) i have strange behavior tinycon library. setBubble method changed favicon only after third call, probably because i have multiple favicons with different sizes.
<link rel="icon" type="image/png" href="http://localhost:8080//s/favicon/favicon-196x196.png" sizes="196x196">
<link rel="icon" type="image/png" href="http://localhost:8080//s/favicon/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="http://localhost:8080//s/favicon/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="http://localhost:8080//s/favicon/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="http://localhost:8080//s/favicon/favicon-128.png" sizes="128x128">
after small investigation i realized that setBubble remove link tags by pieces. HTMLCollection is to blame for this.
this code (attention to comments):
var removeFaviconTag = function(){
var links = document.getElementsByTagName('link');
// links is HTMLCollection
for(var i=0, len=links.length; i < len; i++) {
var exists = (typeof(links[i]) !== 'undefined');
if (exists && (links[i].getAttribute('rel') || '').match(/\bicon\b/i)) {
links[i].parentNode.removeChild(links[i]);
// after removeChild links length stay less by 1
// but loop does not handle this
}
}
};
Imagine that divs in demo it link tags https://codepen.io/mogafk/pen/baMNVL demo demonstrate specificities htmlcollection