https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42248

            Bug ID: 42248
           Summary: Confusing JS code when testing length
   Initiative type: ---
        Sponsorship ---
            status:
           Product: Koha
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Architecture, internals, and plumbing
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]

if (!my_string.length > 0)
is confusing and could be better written:
  if (my_string.length === 0)

Found 4 occurrences:
koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc:
                                 if (!row.cover_image_ids.length > 0) {

koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt:           
if(!borrowernumbers.length > 0) {

koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt:          
             if ( ! $("#title_default").val().length > 0 ) {

koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt:          
                 if ( ! content.length > 0 ) {



```
let content = ""
undefined

content.length
0

!content.length
true

!content.length>0
true 
7m ago
content = "foo"
"foo"

content.length
3

!content.length
false

!content.length>0
false 
```

so... it works, but I am pretty sure it is not interpreted like how the author
thought it would be (and I might be the author).

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to