Skip to content

Commit

Permalink
Throw error on ScrollComponent.wrap() with nonexisting layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Bok committed Jan 7, 2016
1 parent f797a36 commit 3ee6d07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions framer/Components/ScrollComponent.coffee
Expand Up @@ -391,6 +391,9 @@ class exports.ScrollComponent extends Layer

wrapComponent = (instance, layer, options = {correct:true}) ->

if not (layer instanceof Layer)
throw new Error("ScrollComponent.wrap expects a layer, not #{layer}. Are you sure the layer exists?")

# This function wraps the given layer into a scroll or page component. This is
# great for importing from Sketch or Photoshop.

Expand Down
4 changes: 4 additions & 0 deletions test/tests/ScrollComponentTest.coffee
Expand Up @@ -77,3 +77,7 @@ describe "ScrollComponent", ->

delete layerA._properties.backgroundColor
scroll = ScrollComponent.wrap(layerA)

it "should throw a warning on no layer", ->
f = -> ScrollComponent.wrap()
f.should.throw()

0 comments on commit 3ee6d07

Please sign in to comment.