This is not "garbage", they are "expando properties". It shouldn't be a problem in practice for any well-coded JS lib. If your JS lib fails here, it probably means it iterates over the array using a for…in loop: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in#Array_iteration_and_for...in As a workaround, you can probably copy the array into a JsArrayInteger <http://www.gwtproject.org/javadoc/latest/com/google/gwt/core/client/JsArrayInteger.html> : JsArrayInteger arr = JavaScriptObject.createArray().cast(); for (int node : nodes) { arr.push(node); } or using Elemental2 Core: JsArray<Double> arr = new JsArray<>(); for (int node : nodes) { arr.push(node) }
On Tuesday, December 19, 2017 at 8:18:00 AM UTC+1, cesar paulo alves wrote: > > Hello guys, so I'm getting crazy with this. > > I need to inject a java array inside a javascript library. > > The problem is that the Js library will iterate over an integer array, and > if the element is not an integer it exits the function. > When I create the integer array and pass it to plain javascript array, for > some reason it carries garbage inside, I already tried everything with no > success. > > So this is my java nodeset (https://pastebin.com/AdJqj80p) > > > <https://lh3.googleusercontent.com/-AwVwbsEDgEo/WjgDruEwP_I/AAAAAAAACh4/PRODa3vy6Nsb3stgjMkxrhLEmLIOu7tkQCLcBGAs/s1600/Screenshot_20171218_180625.png> > > I'm using the gwt-interop-utils > <https://github.com/GWTReact/gwt-interop-utils> -> > https://github.com/GWTReact/gwt-interop-utils/blob/master/src/gwt/interop/utils/client/plainobjects/JsPlainObj.java > > > And when I inspect the javascript object in the browser you can see it has > lots of garbage, and I cant clean it. See the nodes array I have > (_clazz_0_g$,__elementTypeCategory$,_elementTypeId$"......). > > > <https://lh3.googleusercontent.com/-7LN-93NvDAc/WjgEg4wts7I/AAAAAAAACiE/AJ5jJO9hy7If7kS7EGb0e5_AdV170DsWACLcBGAs/s1600/Screenshot_20171218_180917.png> > > > And when I do the same with Js I don't have this garbage (obvious). > > > <https://lh3.googleusercontent.com/-C1POb2aM3EA/WjgFUx4qlSI/AAAAAAAACiQ/5t1bqZCIAY4pXAbsakpmxHGowXG1eVBngCLcBGAs/s1600/Screenshot_20171218_181337.png> > > > I already used the JsArray and everything, but no luck =/. > > > Do you have any Idea how to have a plain javascript array with jsInterop? > > > Thanks a lot. > > > > > > -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
