ArcBees / gwtquery

A jQuery clone for GWT, and much more.
MIT License
85 stars 38 forks source link

JSNI Error with isWindow (hasProperty) #296

Open BenDol opened 9 years ago

BenDol commented 9 years ago

Getting an error while using GQuery for ChosenListBox library:

com.google.gwt.dev.shell.HostedModeException: Something other than a boolean was returned from JSNI method '@com.google.gwt.query.client.js.JsUtils::hasProperty(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;)': JS value of type null, expected boolean
    at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:100)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeBoolean(ModuleSpace.java:196)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeBoolean(JavaScriptHost.java:35)
    at com.google.gwt.query.client.js.JsUtils.hasProperty(JsUtils.java)
    at com.google.gwt.query.client.js.JsUtils.isWindow(JsUtils.java:383)
    at com.google.gwt.query.client.impl.DocumentStyleImpl.cur(DocumentStyleImpl.java:46)
    at com.google.gwt.query.client.GQuery.position(GQuery.java:3421)
    at nz.co.doltech.framework.libraries.chosen.client.ChosenImpl.resultDoHighlight(ChosenImpl.java:823)
    at nz.co.doltech.framework.libraries.chosen.client.ChosenImpl.winnowResultsSetHighlight(ChosenImpl.java:1432)
    at nz.co.doltech.framework.libraries.chosen.client.ChosenImpl.winnowResults(ChosenImpl.java:1402)
    at nz.co.doltech.framework.libraries.chosen.client.ChosenImpl.resultsShow(ChosenImpl.java:1015)
    at nz.co.doltech.framework.libraries.chosen.client.ChosenImpl.containerMouseDown(ChosenImpl.java:472)
    at nz.co.doltech.framework.libraries.chosen.client.ChosenImpl.access$0(ChosenImpl.java:453)
    at nz.co.doltech.framework.libraries.chosen.client.ChosenImpl$17.execute(ChosenImpl.java:546)
    at com.google.gwt.core.client.impl.SchedulerImpl.execute(SchedulerImpl.java:138)
    at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
    at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Unknown Source)
    private void resultDoHighlight(GQuery el) {
        if (el == null || el.length() == 0) {
            return;
        }

        resultClearHighlight();

        resultHighlight = el;

        resultHighlight.addClass(css.highlighted());

        int maxHeight = (int) searchResults.cur("maxHeight", true);
        int visibleTop = searchResults.scrollTop();
        int visibleBottom = maxHeight + visibleTop;

        // HERE //
        int highTop = resultHighlight.position().top + searchResults.scrollTop();
        int highBottom = highTop + resultHighlight.outerHeight();

        if (highBottom >= visibleBottom) {
            int toScroll = highBottom - maxHeight;
            searchResults.scrollTop(toScroll > 0 ? toScroll : 0);
        } else if (highTop < visibleTop) {
            searchResults.scrollTop(highTop);
        }

    }

Here is where the issue is: GQuery#position()

this    GQuery  (id=455)    
element JavaScriptObject$  (id=236) 
offsetParent    null    
offset  GQuery$Offset  (id=458) 
parentOffset    GQuery$Offset  (id=459) 
topMargin   0   
leftMargin  0   

GQuery#position() isnt accounting for possible null offsetParent.

EDIT: Well the issue was that I was calling setPlaceholderText twice in the ChosenListBox library. Not sure why this caused that issue but I will leave this open until someone looks into it.

BenDol commented 9 years ago

Perhaps I have done something wrong, not sure actually.