1

jQuery Lint を使用して、考えられる jQuery エラーをチェックしたいと考えています。

機能する簡単なスクリプトで試してみたかったのです。jquery lint を含めて問題なくレベル 2 に設定すると、BAM で 3 つのエラーが発生しました。

jQuery(.highlightimage) special check failed

jquery.lint.js (line 100)

More info:

Selector: .highlightimage Selectors should be as specific as possible and should be "class only"

Collection: []

Location:

@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16

@http://localhost:53402/Resources/Scripts/highlights.js:15

@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16

@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16 

何?15 行目は次のとおりです。

hl_elements = $(".highlightimage");

そのエラーはどういう意味ですか? セレクターには 5 つの要素が含まれているため、有効です。それは可能な限り具体的です。

その $(document).ready(function () { /ここにスクリプトがあります/ }); 部。

私のすべてのセレクターはこのように失敗します。私は何を間違っていますか?

jquery 1.6.1 を使用しています。まだサポートされていない可能性がありますが、github には jquery 1.6.1 のテスト ケースが既にあり、正常に動作します。

その他のエラーは次のとおりです。

trigger(ready) called incorrectly
jquery.lint.js (line 100)

More info:
Collection: [Document localhost:53402]

Location:
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16
jquery.lint.js (line 115)
You passed: ["ready"]

Available signatures include:
trigger(eventType, extraParameters)
trigger(event)

ページの読み込み時にそれを取得します。

画像が変更されるたびに、この別のものを取得します。

jQuery.removeData([object HTMLImageElement],fxqueue,true) called incorrectly
jquery.lint.js (line 100)

More info:
Location:
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16 
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:18 
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:18
jquery.lint.js (line 115)
You passed: [img.highlightimage /Documen..._293.png, "fxqueue", true]

Available signatures include:
jQuery.removeData(element, [name])

しかし、jquery 1.4.4 に切り替えると、この最後の問題は発生しません。

4

1 に答える 1

3

https://github.com/jamespadolsey/jQuery-Lint/blob/551c2106ac0daee95a670fb180610d09e58bb4cc/jquery.lint.js#L711のソース コードは次のように述べています。

// クラスのみのセレクターを見つける (IE6-8 のパフォーマンスが低い)

それが警告の理由だと思います。クラスのみのセレクターを使用したい場合は、無視しても問題ないと思います。

(エラーテキストは「クラスのみ」であってはならないということになっていると思います。)

于 2011-06-08T09:10:28.570 に答える