jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.68k stars 516 forks source link

Error uploading file on Chrome OS #331

Closed stuartpb closed 5 years ago

stuartpb commented 6 years ago

I got this error trying to upload a file on Chrome OS Version 62.0.3202.97 (Official Build) (32-bit):

Uncaught TypeError: Cannot read property 'webkitGetAsEntry' of null
Line: 87042,col: 21
(https://openjscad.org/dist/index.js)
kaosat-dev commented 6 years ago

Hi @stuartpb , by 'upload' do you mean drag & drop to display a file ? Is this for the online version or self hosted ?

stuartpb commented 6 years ago

Drag & drop or clicking the button to browse. This is for the online version at https://openjscad.org/.

jameshightower commented 5 years ago

Chrome, at least on ChromOS, puts null's in the DataTransferItem array. I'm not sure why, but this fixes it:

diff --git a/packages/web/dist/index.js b/packages/web/dist/index.js
index dbb5a75..365c3d3 100644
--- a/packages/web/dist/index.js
+++ b/packages/web/dist/index.js
@@ -94509,7 +94509,7 @@ function pseudoArraytoArray(pseudoArray) {
   var array = [];
   for (var i = 0; i < pseudoArray.length; i++) {
     var item = pseudoArray[i];
-    array.push(item.webkitGetAsEntry ? item.webkitGetAsEntry() : item);
+    if (item) array.push(item.webkitGetAsEntry ? item.webkitGetAsEntry() : item);
   }
   return array;
 }