在学习jquery1.72源代码的sizzle模块过程中,看不懂第5200行源代码

源代码这样

        // Check to see if it's possible to do matchesSelector
        // on a disconnected node (IE 9 fails this)
        var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
            pseudoWorks = false;

        try {
            // This should fail with an exception
            // Gecko does not error, returns false instead
            matches.call( document.documentElement, "[test!='']:sizzle" );

        } catch( pseudoError ) {
            pseudoWorks = true;
        }

第5200行代码matches.call( document.documentElement, "[test!='']:sizzle" )看不懂,"[test!='']:sizzle"是css选择器的写法吗,test是属性,sizzle是伪类吗?。。。

阅读 1.8k
2 个回答

难道是为了检测选择器功能是否正常,故意这样写,然后期待抛出异常

看样子是的,这段代码应该是判断浏览器是否支持伪类

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进