Skip to content

Commit

Permalink
Fixing issue with border styles
Browse files Browse the repository at this point in the history
  • Loading branch information
rramo012 committed Nov 27, 2017
1 parent 797655a commit 1a6bcef
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/controls/border/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export class Border extends MultiSlider {
}
}
};

this.borderDirections = [ 'left', 'top', 'right', 'bottom' ];
}

/**
Expand Down Expand Up @@ -60,7 +62,8 @@ export class Border extends MultiSlider {
*/
bindEvents() {
this._bindTypeChange();
this._setType().change();
this.refreshValues();
this._setType();
}

/**
Expand All @@ -69,15 +72,37 @@ export class Border extends MultiSlider {
* @since 1.0.0
*/
_setType() {
let setting = this.$target.css( 'border-style' );
setting = 'none' !== setting ? setting : '';
let setting = this._getBorderStyle();

setting = 'none' !== setting ? setting : '';
return this.$typeControl
.find( '.border-type-control input' )
.filter( '[value="' + setting + '"]' )
.prop( 'checked', true );
}

/**
* Get the currently set border style.
*
* This was added for cross browser support. FF does not return anything for border-style.
*
* @since 0.8.7
*
* @return {string} Currently applied style.
*/
_getBorderStyle() {
let style = '';
for ( let direction of this.borderDirections ) {
let directionalStyle = this.$target.css( 'border-' + direction + '-style' );
if ( 'none' !== directionalStyle ) {
style = directionalStyle;
break;
}
}

return style;
}

/**
* Refresh the values of the input to the values of the target.
*
Expand Down

0 comments on commit 1a6bcef

Please sign in to comment.