鍍金池/ 問答/HTML/ 在學(xué)習(xí)jquery1.72源代碼的sizzle模塊過程中,看不懂第5200行源代

在學(xué)習(xí)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是偽類嗎?。。。

回答
編輯回答
真難過

看樣子是的,這段代碼應(yīng)該是判斷瀏覽器是否支持偽類

2018年9月19日 07:33
編輯回答
短嘆

難道是為了檢測(cè)選擇器功能是否正常,故意這樣寫,然后期待拋出異常

2017年7月14日 12:46