Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QtWebkit doesn't handle Javascript array property accessors well
Forum Updated to NodeBB v4.3 + New Features

QtWebkit doesn't handle Javascript array property accessors well

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 771 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agrawalprash
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved