Opened 6 years ago
Closed 6 years ago
#15192 closed bug (notabug)
Clean code
Reported by: | David Gofman | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | none |
Component: | ui.core | Version: | 1.12.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
I am wondering why you are excluding ===
and !==
validation from jshint.
When I am evaluating code by using jshint I am getting many warning:
Expected !==
and instead saw !=
.
One of critical issue in your core widget on line 35
https://github.com/jquery/jquery-ui/blob/master/ui/widget.js#L35
You are implemented for loop such as:
for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
however ( elem = elems[ i ] )
will never will be null i most cases is "undefined"
If I will change to strong type such as:
for ( i = 0; ( elem = elems[ i ] ) !== null; i++ ) {
I will be in infinite loop and browser will be freezes.
I will suggest make changes and fix this loops as well either:
for ( i = 0; ( elem = elems[ i ] ) !== undefined; i++ )
or
for ( i = 0; !!( elem = elems[ i ] ); i++ )
to handle null and undefined
Thanks, David
Change History (3)
comment:1 Changed 6 years ago by
comment:2 Changed 6 years ago by
Description: | modified (diff) |
---|
comment:3 Changed 6 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
Your coding standards differing from ours is not a bug.
PR: https://github.com/jquery/jquery-ui/pull/1819