1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed XenForo.DisplayIgnoredContent

Discussion in 'Resolved Bug Reports' started by Zumega, Dec 14, 2011.

  1. Zumega

    Zumega New Member

    I was playing with the 'Show Ignored Content' functionality and I was getting a JS error. In FF a security error and in Chrome a 'length' read error. So after some digging I found that since our implementation of XenForo has cross domain CSS added to the site I was getting the error in the XenForo.DisplayIgnoredContent function in the xenforo.js file. The error was happening when the JS went to manipulate the CSS and remove the rules for '.ignore'

    To remove the errors I skip the JS that manipulates the CSS, if the stylesheet has a NULL href and the domain is different:

    Code:
    domain = "'/"+document.domain+"/'";
    if (document.styleSheets)
    {
        for (i = 0; i < (document.styleSheets.length-1); i++)
        {
            styleSheet = document.styleSheets[i];
            if((styleSheet.href != null) && (styleSheet.href.match(domain))){
                rules = (styleSheet.cssRules) ? styleSheet.cssRules : styleSheet.rules;
                for (j = 0; j < rules.length; j++)
                {
                    rule = rules[j];
     
                    if (rule.selectorText && rule.selectorText.toLowerCase() == '.ignored')
                    {
                        if (styleSheet.deleteRule)
                        {
                            styleSheet.deleteRule(j);
                        }
                        else
                        {
                            styleSheet.removeRule(j);
                        }
                    }
                }
            }
        }
    }
    
    Please add this to the xenforo.js as this could be use full to other developers, thanks.
     
  2. Mike

    Mike XenForo Developer Staff Member

    Fixed this with a try-catch around the rules access. That seems to fix it for all browsers.
     
  3. Zumega

    Zumega New Member

    Cool Thanks.
     

Share This Page