Skip to content

Commit

Permalink
Merge pull request gwtbootstrap3#432 from sjardine/master
Browse files Browse the repository at this point in the history
Fixes problem when Icon was inserted into DOM even if IconType was null.
  • Loading branch information
sjardine committed Oct 28, 2015
2 parents 728a105 + 5fb6fdd commit 3c75cc1
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,24 +199,27 @@ public void execute() {

if (icon != null) {
icon.removeFromParent();
icon = null;
}

icon = new Icon();
icon.setType(iconType);
icon.setSize(iconSize);
icon.setFlip(iconFlip);
icon.setRotate(iconRotate);
icon.setSpin(iconSpin);
icon.setPulse(iconPulse);
icon.setBorder(iconBordered);
icon.setFixedWidth(iconFixedWidth);
icon.setInverse(iconInverse);
if (iconType != null) {
icon = new Icon();
icon.setType(iconType);
icon.setSize(iconSize);
icon.setFlip(iconFlip);
icon.setRotate(iconRotate);
icon.setSpin(iconSpin);
icon.setPulse(iconPulse);
icon.setBorder(iconBordered);
icon.setFixedWidth(iconFixedWidth);
icon.setInverse(iconInverse);
}

// Since we are dealing with Icon/Text, we can insert them at the right position
// Helps on widgets like ButtonDropDown, where it has a caret added
int position = 0;

if (iconPosition == IconPosition.LEFT) {
if (icon != null && iconPosition == IconPosition.LEFT) {
widget.insert(icon, position++);
widget.insert(separator, position++);
}
Expand All @@ -225,7 +228,7 @@ public void execute() {
widget.insert(text, position);
}

if (iconPosition == IconPosition.RIGHT) {
if (icon != null && iconPosition == IconPosition.RIGHT) {
widget.insert(separator, position++);
widget.insert(icon, position);
}
Expand Down

0 comments on commit 3c75cc1

Please sign in to comment.