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

Mutation Summary gets clogged #12

Open
blpraveen opened this issue Jun 2, 2015 · 1 comment
Open

Mutation Summary gets clogged #12

blpraveen opened this issue Jun 2, 2015 · 1 comment

Comments

@blpraveen
Copy link

I have been using mutation summary with one of the firefox addon I have developed.
I used it observer anchors with mailto link. It was all working fine.
Recently our colleque reported its system gets clogged when pages loads.
Myself looked at the page I see a very large data being loaded via ajax and firefox memory get exhaust. Suddenly the page gets hanged and after sometime popup error shows that it stopped while executing the mutation summary.
Please Advise

@blpraveen
Copy link
Author

Here is my function

addEventToMailToLink : function(e){     

  if ( myfunction.getBoolPref('disablemyaddon', false) )
      return;

  try{


    var doc = e.originalTarget;
    var obs = new MutationSummary({
             rootNode: doc,
            callback: myfunction.addEventToMutationMarkup,
            queries: [{ element: "a[href]"}] //element: "a[href^='mailto:']"
            });     
      var links = doc.getElementsByTagName('a');
      if ( !links || links.length == 0 )
          return;
      for(var i =0; i < links.length; i++){
          var link = links[i];
          if ( link.protocol && link.protocol == "mailto:"  ){
              link.setAttribute("onclick", "return false;");
              link.addEventListener("click",myfunction.mailtoLinkClick,true);
          }
      }
  }catch( e ){ alert(e.message);} 
 },

How can I improve it to avoid clog

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

No branches or pull requests

1 participant