Skip to content

Commit

Permalink
Check layer value types
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbok committed Sep 25, 2014
1 parent 4686f4f commit 48028d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions framer/Layer.coffee
Expand Up @@ -21,6 +21,9 @@ layerProperty = (obj, name, cssProperty, fallback, validator, set) ->

set: (value) ->

if value and validator and not validator(value)
throw new Error("Layer.#{name}: value '#{value}' of type '#{typeof(value)}'' is not valid")

@_properties[name] = value
@_element.style[cssProperty] = LayerStyle[cssProperty](@)

Expand Down
7 changes: 7 additions & 0 deletions test/tests/LayerTest.coffee
Expand Up @@ -233,6 +233,13 @@ describe "Layer", ->
layer.backgroundColor.should.equal "red"
layer.style["backgroundColor"].should.equal "red"

it "should check value type", ->

f = ->
layer = new Layer
layer.x = "hello"
f.should.throw()


describe "Filter Properties", ->

Expand Down

0 comments on commit 48028d3

Please sign in to comment.