diff --git a/framer/Components/ScrollComponent.coffee b/framer/Components/ScrollComponent.coffee index 94930d0c1..129a1408e 100644 --- a/framer/Components/ScrollComponent.coffee +++ b/framer/Components/ScrollComponent.coffee @@ -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. diff --git a/test/tests/ScrollComponentTest.coffee b/test/tests/ScrollComponentTest.coffee index 14cc3de71..953b48dc0 100644 --- a/test/tests/ScrollComponentTest.coffee +++ b/test/tests/ScrollComponentTest.coffee @@ -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()