Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1479] Regression: Model instance data binding no longer works

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-03-30T21:20:19.000+0000
Affected Version/salloy 1.8.3, alloy 1.8.4
Fix Version/sRelease 5.2.2, alloy 1.8.4, alloy 1.8.5
ComponentsModels
Labelsn/a
ReporterFokke Zandbergen
AssigneeFokke Zandbergen
Created2016-03-30T13:41:20.000+0000
Updated2016-03-31T23:27:44.000+0000

Description

Data binding of local model instances throws an exception in Alloy 1.8.3 and 1.8.4 because of [this line change](https://github.com/appcelerator/alloy/pull/769/files#diff-a59a2178e486f81366775c39e5393695L521) to resolve ALOY-1369. *XML*
		<Label top="20" text="{$.modelinstance.foo}" />
		<Label text="{$.modelinstance.foo} {$.modelinstance.bar}" />
*compiled*
        $.__alloyId4.text = _.template("{$.modelinstance.foo}", {
            modelinstance: transformed
        }, {
            interpolate: /\{([\s\S]+?)\}/g
        });
        $.__alloyId5.text = _.template("{$.modelinstance.foo} {$.modelinstance.bar}", {
            modelinstance: transformed
        }, {
            interpolate: /\{([\s\S]+?)\}/g
        });

Comments

  1. Fokke Zandbergen 2016-03-30

    /cc [~cng] [~emerriman] [~fmiao]
  2. Fokke Zandbergen 2016-03-30

    I'm including a test app that covers all of the following cases:

    Simple global model data binding

    Complex global model data binding

    Complex global model data binding with undefined model attribute

    Simple local model instance data binding

    Complex local model instance data binding

    Complex local model instance data binding with undefined model attribute

    Simple global collection data binding

    Complex global collection data binding

    Complex global collection data binding with undefined model attribute

    Simple local collection instance data binding

    Complex local collection instance data binding

    Complex local collection instance data binding with undefined model attribute

    Simple global collection data binding in required view

    Complex global collection data binding in required view

    Complex global collection data binding in required view with undefined model attribute

    Simple local collection instance data binding in required view

    Complex local collection instance data binding in required view

    Complex local collection instance data binding in required view with undefined model attribute

    The following cases are already covered by the test app for ALOY-1474:

    Simple global model data binding

    Complex global model data binding

    Simple global model data binding with model transform method

    Complex global model data binding with model transform method

    Simple global collection data binding

    Complex global collection data binding

    Complex global collection data binding with controller transform method

    Simple global collection data binding with model transform method

    Complex global collection data binding with model transform method

    Complex global collection data binding with model transform method, overridden by controller transform method

    That should do it.
  3. Fokke Zandbergen 2016-03-30

    PR with test instructions: https://github.com/appcelerator/alloy/pull/779 Did you know we had 0 tests for data binding local instances of models or collections?
  4. Feon Sua Xin Miao 2016-03-30

    We do have tests for local instance of collection, i.e https://github.com/appcelerator/alloy/blob/master/test/apps/testing/ALOY-874/ Overall, the list you have is bulletproof, and the fix looks good!
  5. Fokke Zandbergen 2016-03-30

    That's for a collection. Do we also have one for a instance of a model?
  6. Feon Sua Xin Miao 2016-03-30

    We now do! You just added it! :)
  7. Feon Sua Xin Miao 2016-03-30

    PR merged. Alloy@1.8.5
  8. Eric Wieber 2016-03-31

    Verified fixed, using: MacOS 10.11.4 (15E65) Studio 4.5.0.201602170821 Ti SDK 5.2.2.v20160328141205 Appc NPM 4.2.5-1 Appc CLI 5.2.2-3 Alloy 1.8.5 Xcode 7.3 (7D175) Data binding for models is working as expected. Tested using the test app provided by Fokke as well as other created test apps. No exception is encountered and model data is correctly shown.

JSON Source