FireFox警告“未知的伪类或伪元素'隐藏'”一直在跑 [英] FireFox warning "Unknown pseudo-class or pseudo-element 'hidden' " keeps running over and over

查看:149
本文介绍了FireFox警告“未知的伪类或伪元素'隐藏'”一直在跑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Firefox中发现了一个警告:

I recently have discovered a warning happening in Firefox that says


警告:未知的伪类或伪元素'隐藏'

Warning: Unknown pseudo-class or pseudo-element 'hidden'

这是页面 http://eleven23.net/eleven23/beta/work/web/lounge22.php

当它到达具有img:hidden的javascript部分时发出警告

And the warning happens when it gets to the part of javascript that has img:hidden


$('img:hidden')。 eq(0).fadeIn(500); //逐个淡入隐藏的图像
i ++; //在计数中加1

$('img:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one i++;//add 1 to the count

所以我想知道是否有人知道如何解决这个警告。

So Im wondering if anyone has an idea on how to resolve this warning.

谢谢!

推荐答案

第一步是真正停止通过 setInterval 重复调用 doThis()此时此刻不会发生。因此警告每500ms出现一次。

The first step is to really stop the repeated calling of doThis() via setInterval which at the moment doesn't happen. Thus the warning appears every 500ms.

更改

$(document).ready (function() {
  var int = setInterval("doThis(i)",500);
});

$(document).ready (function() {
  int = setInterval("doThis(i)",500);
});

否则您对 clearInterval(int)的调用你不会做任何事情,因为你宣布 var int 两次并尝试清除不是间隔的外部int。

Else your call to clearInterval(int) won't do anything as you declared var int twice and try to clear the "outer" int which isn't the interval.

在此修复之后,只有4-5的此警告应保留在您的控制台中。

After this fix only 4-5 of this warning should remain in your console.

现在到您的错误。你可以做很多事情来阻止这个错误出现多次你打电话 doThis()

Now to your error. There isn't much you can do to stop this error from appearing exactly that many times you call doThis().

jQuery在内部使用Sizzle作为选择器引擎。在某些情况下,Sizzle尝试使用(在支持的浏览器上) querySelectorAll() 用于查找与您的选择器匹配的元素。

jQuery uses Sizzle internally as selector engine. And in some cases Sizzle tries to use (on browsers supported) the querySelectorAll() function to find the elements matching your selector.

现在AFAIK 隐藏不是有效的CSS选择器,因此虽然Firefox支持对 querySelectorAll()的调用但在遇到未知选择器后它正确失败。 jQuery捕获错误,然后选择 image:hidden 本身。

Now AFAIK is hidden not a valid CSS selector thus although Firefox supports the call to querySelectorAll() it correctly fails after encountering an unknown selector. jQuery catches the error and then does the selection of image:hidden itself.

如果你不想看到这个错误你可以使用不同的jQuery语法,在这种情况下会阻止Sizzle尝试使用 querySelectorAll()

If you don't want to see this error at all you can use a different jQuery syntax which in this case would stop Sizzle from trying to attempt to use querySelectorAll().

更改

$('img:hidden').eq(0).fadeIn(500);

$('img:hidden', $('div#content_wrapper')).eq(0).fadeIn(500);

但我不建议你这样做,因为它不会让你太多只有4在您的控制台中减少-5个警告。

But I don't advise you to do this as it doesn't really get you much only 4-5 warnings less in your console.

这篇关于FireFox警告“未知的伪类或伪元素'隐藏'”一直在跑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆