Do not allow root view to set a font-size less than 1

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-06-15 17:27:42 -07:00
parent db69ee5627
commit c02e5bbdbf
2 changed files with 8 additions and 0 deletions

View File

@@ -470,3 +470,10 @@ describe "RootView", ->
expect(rootView.getFontSize()).toBe fontSizeBefore + 1
rootView.trigger 'decrease-font-size'
expect(rootView.getFontSize()).toBe fontSizeBefore
it "does not allow the font size to be less than 1", ->
rootView.setFontSize(1)
expect(rootView.getFontSize()).toBe 1
rootView.setFontSize(0)
expect(rootView.getFontSize()).toBe 1

View File

@@ -155,6 +155,7 @@ class RootView extends View
super
setFontSize: (newFontSize) ->
newFontSize = Math.max(1, newFontSize)
[oldFontSize, @fontSize] = [@fontSize, newFontSize]
@trigger 'font-size-change' if oldFontSize != newFontSize