2

私はJSLintで少し苦労しています。次のコードがあります。

// inside a for-loop
if ( aMatch.length > 0 ){
    temp =  wrap.find( aMatch );                                
    break;
} else if ( aMatch.length === 0 && o.siteMap[targetPath].length !== 0 ){
    temp = targetPath;
    break;
}

JSLint は不平を言います:

Empty block   "if ( aMatch.length > 0 ){"

質問:
スニペットの問題は何ですか。「ブロック」は私にとって空ではありません...

いくつかの洞察をありがとう!

編集
これは質問の機能全体です(コメントはありません)

loopHistory: function (scope, setPageContainer) {

    var self = this,
        o = self.options,
        wrap = $('div:jqmData(wrapper="true")').length > 1 ? $('div:jqmData(wrapper="true")').last() : $('div:jqmData(wrapper="true")'),
        $loopLength = $.mobile.urlHistory.stack.length-1, 
        temp, aMatch, parsedPath, dUrl, targetPath, i;

    if ( scope === "internal") {
        if ( $loopLength >= 2) {

            for ( i = $loopLength; i>1; i--) {
                parsedPath = $.mobile.path.parseUrl( $.mobile.urlHistory.stack[i-1].url );      
                targetPath = parsedPath.search.length !== "" ? ( parsedPath.pathname + parsedPath.search ) : parsedPath.pathname;

            if ( setPageContainer.jqmData('id') === $.mobile.urlHistory.stack[i-1].pageContainer.jqmData('id') && targetPath !== $.mobile.path.parseUrl( $.mobile.urlHistory.stack[$.mobile.urlHistory.activeIndex].pageUrl ).pathname ) {

                aMatch = $('div.ui-page').filter(function(){ return $(this).jqmData('url') === targetPath; });

                if ( aMatch.length === 0 && o.siteMap[targetPath].length !== 0 ){

                }

                ... ahh yes.... 
                if ( aMatch.length > 0 ){
                    temp =  wrap.find( aMatch );                                
                    break;

わかった。そうですか...

4

1 に答える 1

6

Ok。私の悪い。JSLintによって言及されたブロックの直前に空のif-elseブロックがありました。

if ( aMatch.length === 0 && o.siteMap[targetPath].length !== 0 ){  }


if ( aMatch.length > 0 ){
   temp =  wrap.find( aMatch );                                
   break;

気づかなかった。

于 2012-11-04T09:24:13.830 に答える