Fixed Javascript error on xfInsert

sonnb

Well-known member
Hello,

There are some users might experience with javascript error on xfInsert event. This might occur on new reply or after inline-edit the post. The post disappear but could not be shown again.

The javascript console would show:

NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMWindow.getComputedStyle]

...conds();wa=na.getUTCMilliseconds();}na=(pa<=0||pa>=10000?(pa<0?"-":"+")+o(6,pa<0...

This kind of error does not occur on all browsers, this might cause by jQuery library or conflict with another library.

After investigate I see that in XF source code:
HTML:
xfInsert: function(insertMethod, insertReference, animateMethod, animateSpeed, callback)
        {
            if (insertMethod == 'replaceAll')
            {
                $(insertReference).xfFadeUp(animateSpeed);
            }
 
            this
                .addClass('__XenForoActivator')
                .hide()
                [insertMethod || 'appendTo'](insertReference)
                .xfActivate()
                [animateMethod || 'xfFadeDown'](animateSpeed, callback);
 
            return this;
        },

You could see that XF would hide the element first then later use fadeDown function to use show up animation.

This could be easy resolved by change
Code:
hide() to .css('display', 'none)

This is strange since hide() function is shortcut to set css display property to none. But I think in the next version, we should use css('display', 'none) instead of hide() to avoid this kind of problem.
 
maybe it's something they will fix when they will use a newer jquery library, most likely not in a minor release as 1.1.x. More likely in a 1.x release.
 
I think this change should be ok - the animate function has various code in it to determine which display to move to. Though if someone had a consistent reproduction case, that'd be helpful.
 
Top Bottom