Making WordPress.org


Ignore:
Timestamp:
07/28/2016 11:27:16 PM (6 years ago)
Author:
obenland
Message:

Plugin Directory: Fix rounding errors for rating stars.

See #1719.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/client/components/plugin-ratings/stars/index.jsx

    r3734 r3735  
    1010            i = 0;
    1111
    12         for ( i; i <= 5; i++ ) {
     12        for ( i; i < 5; i++ ) {
    1313            switch ( counter ) {
    1414                case 0:
     
    3131
    3232    render() {
    33         const rating      = Math.round( this.props.rating / 0.5 ) * 0.5,
    34             titleTemplate = '%s out of 5 stars',
    35             title         = titleTemplate.replace( '%s', rating );
     33        const titleTemplate = '%s out of 5 stars',
     34            title = titleTemplate.replace( '%s', this.props.rating / 20 );
    3635
    3736        return (
     
    4039                title={ title }
    4140                data-title-template={ titleTemplate }
    42                 data-rating={ rating }
    43                 dangerouslySetInnerHTML={ { __html: this.fillStars( rating ) } }
     41                data-rating={ this.props.rating / 20 }
     42                dangerouslySetInnerHTML={ { __html: this.fillStars( Math.round( this.props.rating / 10 ) / 2 ) } }
    4443            ></div>
    4544        )
Note: See TracChangeset for help on using the changeset viewer.