Question

Javascript in a web application runs the following loop:

    for (var name in this) {
        if(typeof(this[name]) == "function") {
            if((/^on_|^do_/).test(name)) {
        console.debug("Adding ", name, " to ", this, "(", this[name], ")");
                f = this[name].bind;
        console.debug(f);
                this[name] = this[name].bind(this);
            }
        }
    }

Under Chrome 24.0.1312.56, the line f = this[name].bind correctly sets f to the native code function.bind(), while in my QWebKit Qt application it sets f to 'undefined'.

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind

Any idea how I'd be able to convince QtWebkit to behave correctly here?


Apparently, Function.prototype.bind is part of ECMAScript 5. It's implementation in webkit should be covered by (fixed bug): https://bugs.webkit.org/show_bug.cgi?id=26382

Perhaps there is a mode to enable ECMAScript 5 that i'm missing?


Apparently i'm using version 534.34 for QtWebkit:

(Pdb) str(QtWebKit.qWebKitVersion()) '534.34'

Which according to this: https://trac.webkit.org/changeset/85696/trunk/Source/WebKit/mac/Configurations/Version.xcconfig

Corresponds to revision 85696. Combined with the comment in the above bug ("Fixed in r95751"), seems like I need a newer version, specifically anything better than 535.5. Now to find what version of PyQt uses that...

Thanks.

Was it helpful?

Solution

It seems that the latest version of PyQt (4.9.6-1) is compiled against wekbit version 534.34. The first release of webkit that supports Function.prototype.bind is 535.5.

In addition, it seems that both PySite 1.2.2 and PyQt 4.9.6-1 report webkit version 535.34, and do not have Function.prototype.bind.

OTHER TIPS

Try using the following code which forces you to use Function.prototype.bind

this[name] = Function.prototype.bind.call(this[name], this)

In IE, some of the host objects don't have a bind method on their methods (functions)... could be something related.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top