Skip to content

Commit

Permalink
Mobile Switch: fix bug when domStyle.get() returns empty string (#324)
Browse files Browse the repository at this point in the history
* Exit early if 'rdef' is falsy
* Remove unused 'id' variable
* Don't create mask if 'rx' or 'ry' are 0 (0 results in no rounded border)
  • Loading branch information
msssk authored Jun 8, 2020
1 parent 47d1b30 commit 91033b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mobile/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,13 @@ define([
this._hasMaskImage = true;
if(!(has("mask-image"))){ return; }
var rDef = domStyle.get(this.left, "borderTopLeftRadius");
if(rDef == "0px"){ return; }
if(!rDef || rDef == "0px"){ return; }
var rDefs = rDef.split(" ");
var rx = parseFloat(rDefs[0]), ry = (rDefs.length == 1) ? rx : parseFloat(rDefs[1]);
var id = (this.shape+"Mask"+w+h+rx+ry).replace(/\./,"_");

maskUtils.createRoundMask(this.switchNode, 0, 0, 0, 0, w, h, rx, ry, 1);
if(rx && ry){
maskUtils.createRoundMask(this.switchNode, 0, 0, 0, 0, w, h, rx, ry, 1);
}
},

_onClick: function(e){
Expand Down

0 comments on commit 91033b7

Please sign in to comment.