Skip to content

Conversation

@gibson042
Copy link
Member

not present: < 0
present: > -1
at index: === N

(cherry picked from commit 509406d)

   raw     gz Compared to compat @ 2866da9e12b7cf339667ae894ffe072f4eb673de    
    +9     +4 dist/jquery.js                                                   
    +1     -4 dist/jquery.min.js

Ref #1984

not present: `< 0`
present: `> -1`
at index: `=== N`

(cherry picked from commit 509406d)
@dmethvin
Copy link
Member

dmethvin commented Jan 2, 2015

I'm good with this, consistency is always nice if there's no compelling reason to be inconsistent.

@markelog
Copy link
Member

markelog commented Jan 3, 2015

Yeah, but i fear we will forget about this convention pretty quicky, plus it's not standardized across all the projects

@gibson042
Copy link
Member Author

It's a little esoteric, but we could put this in the style guide. The corresponding text would be something like "strict ordered comparison" (this PR: index < 0, index > -1), "ordered comparison to zero" (index < 0, index >= 0), "equality comparison" (index === -1, index !== -1), etc. At a glance, globalize seems to use equality comparison and qunit is inconsistent. I'm not feeling ambitious enough to look at jquery-mobile or jquery-ui right now.

@gibson042
Copy link
Member Author

I just checked the git builds for each. The modes for Mobile are (index === -1, index > -1) and for UI are (index === -1, index !== -1), although each has a single "not present" index < 0 and both exhibit a few "present" variations (Mobile even has three !!~index patterns).

cc @arschmitz, @scottgonzalez

@scottgonzalez
Copy link
Member

I feel like this is getting into the weeds, unless there's a strong reason to be extremely consistent.

With that being said, if a linter is going to find these, then I don't care what we do.

@arschmitz
Copy link
Member

Im not strongly opinionated here either. If we are going to do something though i would like it to be in the style guide or as @markelog said it will quickly be forgotten and not enforced.

gibson042 added a commit that referenced this pull request Jan 11, 2015
not present: `< 0`
present: `> -1`
at index: `=== N`

(cherry picked from commit 53aa87f)

Closes gh-1985
@gibson042
Copy link
Member Author

Closed by 6ae222a

@gibson042 gibson042 closed this Jan 11, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

5 participants