From 91033b727e1d9a1694dc4d3a1662d3409fe334d4 Mon Sep 17 00:00:00 2001 From: Mangala Sadhu Sangeet Singh Khalsa Date: Mon, 8 Jun 2020 16:01:12 -0700 Subject: [PATCH] Mobile Switch: fix bug when domStyle.get() returns empty string (#324) * 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) --- mobile/Switch.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mobile/Switch.js b/mobile/Switch.js index 024dc1d1de..47fffb0338 100644 --- a/mobile/Switch.js +++ b/mobile/Switch.js @@ -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){