Quantcast
Channel: Qt DevNet forums: Qt WebKit
Viewing all articles
Browse latest Browse all 542

QtWebkit doesn't handle Javascript array property accessors well

$
0
0
Hello all, I am having trouble trying to make Javascript array property accessors work properly in QtWebkit shipped with Qt 4.8. For example, if I do the following in the QtWebkit web inspector: var _a = [1]; var a = []; Object.defineProperty(a, '0', {               get: function(){                          console.log('getter called');                          return _a[0];                        },               set: function(val){                       console.log('setter called');                       _a[0] = val;                       } }) it should define a numeric property ‘0’ on the array object, so that if I do: console.log(a[0]); it should call the defined getter and return the value of _a [ 0 ], that is, 1. All the latest webkit browsers (Chrome/Safari) return 1 as expected. But QtWebkit returns an `undefined`, without calling the getter at all. I discovered that setting a.length = 1 solves the problem and the getters start working fine. The problem however still remains in setters. When I do: a[0] = 5; the setter is never called as I don’t get the expected log – ‘setter called’ – on the console. Again, the latest webkit browsers (Chrome/Safari) do the right thing and call the defined setter as expected. Does anyone know if there is a quick workaround this problem (like the one I accidentally discovered with getters) so that I could have array setters work properly? Or if this is really a deep nested bug, would it be fixed it Qt 5? Thanks a lot in advance. Prashant

Viewing all articles
Browse latest Browse all 542

Trending Articles