Titanium Mobile
  1. Titanium Mobile
  2. TIMOB-5818

Ti API: View proxies should behave like real JS objects - or they should be wrapped

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Medium Medium
    • Resolution: Unresolved
    • Affects Version/s: Release 1.7.3
    • Fix Version/s: Release 4.1.0
    • Component/s: TiAPI
    • Environment:

      Titanium Mobile 1.7.3

      Description

      Component: Ti API

      If view proxies aren't going to behave like real JS objects (e.g. nested properties of proxy objects are immutable), and that isn't going to change, I propose we should develop a pure-JS API that wraps the proxies.

      I've begun wrapping Ti views in my SproutCore-Titanium project.

      Let's get a discussion started.

        Activity

        Hide
        me@mattapperson.com added a comment - - edited

        As something to consider here.. this works on android (at least as of 3.1.0 preview) but not iOS:

        var win = Ti.UI.createWindow({
            open: function() {
                alert('test');
            }
        });
        win.open(); // an alert is opened with test displayed on Android, on iOS nothing happens
         
        {code)
         
        However this still does not mean it supports prototype as:
        
        

        win.protoype;

         

        is undefined

        Show
        me@mattapperson.com added a comment - - edited As something to consider here.. this works on android (at least as of 3.1.0 preview) but not iOS: var win = Ti.UI.createWindow({ open: function() { alert('test'); } }); win.open(); // an alert is opened with test displayed on Android, on iOS nothing happens   {code)   However this still does not mean it supports prototype as: win.protoype;   is undefined
        Hide
        Ivan Skugor added a comment -

        It's due to this (unfortunately, declared as invalid) bug: https://jira.appcelerator.org/browse/TIMOB-10829

        Show
        Ivan Skugor added a comment - It's due to this (unfortunately, declared as invalid) bug: https://jira.appcelerator.org/browse/TIMOB-10829
        Hide
        Neeraj Gupta added a comment -

        https://jira.appcelerator.org/browse/TIMOB-10829 has been reopened and we are going to take a closer look at that ticket.

        Show
        Neeraj Gupta added a comment - https://jira.appcelerator.org/browse/TIMOB-10829 has been reopened and we are going to take a closer look at that ticket.
        Hide
        Ivan Skugor added a comment -

        Thanks

        Show
        Ivan Skugor added a comment - Thanks
        Hide
        Pier Paolo Ramon added a comment -

        Another interesting issue related to this topic:

         
        var obj = {};
        var label = Ti.UI.createLabel({ text: 'Some text' });
         
        printPropertyDescriptor(label, 'text');
        printPropertyDescriptor(label, 'idontexist');
        printPropertyDescriptor(obj, 'idontexist');
         
        function printPropertyDescriptor(obj, name) {
        	var descriptor = Object.getOwnPropertyDescriptor(obj, 'clearTimeout');
        	var formatted = JSON.stringify(descriptor, null, 2);
        	console.log(name + " = " + formatted);
        }
        

        prints:

        [INFO] :   text = {
        [INFO] :     "writable": false,
        [INFO] :     "enumerable": false,
        [INFO] :     "configurable": true
        [INFO] :   }
        [INFO] :   idontexist = {
        [INFO] :     "writable": false,
        [INFO] :     "enumerable": false,
        [INFO] :     "configurable": true
        [INFO] :   }
        [INFO] :   idontexist = undefined
        

        but the expected result is

        [INFO] :   text = {
        [INFO] :     "writable": false,
        [INFO] :     "enumerable": false,
        [INFO] :     "configurable": true,
        [INFO] :     "value": 'Some text',
        [INFO] :   }
        [INFO] :   idontexist = undefined
        [INFO] :   idontexist = undefined
        

        So Object.getOwnPropertyDescriptor for proxies returns always writable:false, enumerable:false, configurable:true.

        Funny.

        Show
        Pier Paolo Ramon added a comment - Another interesting issue related to this topic:   var obj = {}; var label = Ti.UI.createLabel({ text: 'Some text' });   printPropertyDescriptor(label, 'text' ); printPropertyDescriptor(label, 'idontexist' ); printPropertyDescriptor(obj, 'idontexist' );   function printPropertyDescriptor(obj, name) { var descriptor = Object.getOwnPropertyDescriptor(obj, 'clearTimeout' ); var formatted = JSON.stringify(descriptor, null , 2); console.log(name + " = " + formatted); } prints: [INFO] : text = { [INFO] : "writable": false, [INFO] : "enumerable": false, [INFO] : "configurable": true [INFO] : } [INFO] : idontexist = { [INFO] : "writable": false, [INFO] : "enumerable": false, [INFO] : "configurable": true [INFO] : } [INFO] : idontexist = undefined but the expected result is [INFO] : text = { [INFO] : "writable": false, [INFO] : "enumerable": false, [INFO] : "configurable": true, [INFO] : "value": 'Some text', [INFO] : } [INFO] : idontexist = undefined [INFO] : idontexist = undefined So Object.getOwnPropertyDescriptor for proxies returns always writable:false, enumerable:false, configurable:true . Funny.

          People

          • Assignee:
            Ingo Muschenetz
            Reporter:
            Erik Bryn
          • Watchers:
            17 Start watching this issue

            Dates

            • Created:
              Updated:

              Development

                Poker Sessions

                This issue is currently not assigned to any Poker Session.