WordPress.org

Support

Support » Requests and Feedback » Bug inside media-views.js?

Bug inside media-views.js?

  • NumberKruncher
    Member

    @numberkruncher

    I have created a hook which adds two controls to the “Edit Gallery” page (a “select” and a “checkbox”). The “select” control is working absolutely fine, but the checkbox is not working at all.

    It seems that the culprit is on line #3939 of media-views.js:

    } else if ( $setting.is('input[type="checkbox"]') ) {
        $setting.attr( 'checked', !! value );
    }

    When the checkbox is selected value is “true” (string type). When the checkbox is not selected, value is “false” (string type). The double-bang does not work in the case of string encoded boolean values:

    var stringTrue = 'true';
    var stringFalse = 'false';
    var boolTrue = true;
    var boolFalse = false;
    
    !!stringTrue // true
    !!stringFalse // true (correct, but wrong!!)
    !!boolTrue // true
    !!boolFalse // false

    This seems like a bug to me, am I right?

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug inside media-views.js?’ is closed to new replies.