From 9cc34d7406c760062bc2c1e096efcf2b15cd1719 Mon Sep 17 00:00:00 2001
From: Karishma Chadha <kchadha@scratch.mit.edu>
Date: Thu, 3 May 2018 13:37:45 -0400
Subject: [PATCH] Fix attribute of block so that it doesn't have errors if
 referenced target doesn't exist.

---
 src/blocks/scratch3_sensing.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/blocks/scratch3_sensing.js b/src/blocks/scratch3_sensing.js
index 9cd50c45d..93b8fb26b 100644
--- a/src/blocks/scratch3_sensing.js
+++ b/src/blocks/scratch3_sensing.js
@@ -264,6 +264,11 @@ class Scratch3SensingBlocks {
             attrTarget = this.runtime.getSpriteTargetByName(args.OBJECT);
         }
 
+        // attrTarget can be undefined if the target does not exist
+        // (e.g. single sprite uploaded from larger project referencing
+        // another sprite that wasn't uploaded)
+        if (!attrTarget) return 0;
+
         // Generic attributes
         if (attrTarget.isStage) {
             switch (args.PROPERTY) {