Fix requirement of KorAP.vc in docGroupRef

Change-Id: I9b273e460f40d09e2aad33b69a922f15328fc7ac
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index 7beede7..83ee822 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -658,6 +658,9 @@
 
   
   describe('KorAP.VC.UnspecifiedDoc', function () {
+
+    KorAP.vc = undefined;
+    
     it('should be initializable', function () {
       var doc = unspecifiedClass.create();
       var docElement = doc.element();
@@ -1288,7 +1291,7 @@
       expect(vcE.firstChild.children[1].getAttribute('data-type')).toEqual('string');
       expect(vcE.firstChild.children[1].textContent).toEqual("myCorpus");
     });
-
+   
     it('should be based on a nested docGroup', function () {
       var vc = nestedGroupFactory.create();
 
@@ -1323,6 +1326,28 @@
       expect(vc.toQuery()).toEqual('referTo "myCorpus" & Titel = "Baum"');
     });
 
+    it('should accept an undefined KorAP.vc', function () {
+      let temp = KorAP.vc;
+      KorAP.vc = undefined;
+      const vc = vcClass.create().fromJson({
+        "@type" : "koral:docGroup",
+        "operation" : "operation:and",
+        "operands" : [{
+          "@type" : "koral:docGroupRef",
+          "ref":"myCorpus"
+        },{
+          "@type" : "koral:doc",
+          "key":"Titel",
+          "value":"Baum",
+          "match":"match:eq"
+        }]
+      });
+
+      expect(vc._root.ldType()).toEqual("docGroup");
+      expect(vc.toQuery()).toEqual('referTo "myCorpus" & Titel = "Baum"');
+
+      KorAP.vc = temp;
+    });    
     
     it('should be modifiable by deletion in flat docGroups', function () {
       var vc = flatGroupFactory.create();
diff --git a/dev/js/src/vc/docgroupref.js b/dev/js/src/vc/docgroupref.js
index 5a9196b..3709c63 100644
--- a/dev/js/src/vc/docgroupref.js
+++ b/dev/js/src/vc/docgroupref.js
@@ -60,12 +60,12 @@
 
       // Set ref - TODO: Cleanup!
       e.refTo = t;
-
+     
       // Was rewritten
       if (t.rewrites() !== undefined) {
         e.classList.add("rewritten");
       };
-
+     
       const refTitle = document.createElement('span');
       refTitle.classList.add('key','fixed', 'ref');
       refTitle.addT('referTo');
@@ -101,7 +101,7 @@
       if (t._rewrites !== undefined) {
         e.appendChild(t._rewrites.element());
       };
-
+     
       if (t._parent !== undefined) {
 
         // Set operators
@@ -112,10 +112,12 @@
           true
         ).element());
       };  
-     
-      KorAP.vc.element().dispatchEvent(
-        new CustomEvent('vcChange', { 'detail' : t })
-      );
+
+      if (KorAP.vc !== undefined) {
+        KorAP.vc.element().dispatchEvent(
+          new CustomEvent('vcChange', { 'detail' : t })
+        );
+      };
       
       return t.element();
     },