Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert htmlcollection to simple array #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mogafk
Copy link

@mogafk mogafk commented Jan 11, 2018

(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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant