[ALOY-1371] Make Alloy less dependent on knowledge about Titanium APIs for parsing XML
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | None |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | XML |
Labels | n/a |
Reporter | Fokke Zandbergen |
Assignee | Bruce Wayne |
Created | 2016-03-18T12:51:15.000+0000 |
Updated | 2016-03-18T14:07:08.000+0000 |
Description
ALOY-1363 got me thinking it would be good to make Alloy less dependent on knowledge about the Titanium APIs for parsing XML.
Why
* Less dependant on certain Titanium versions (e.g. should<SplitView>
map to Ti.UI.iPad
or Ti.UI.iOS
namespace?)
* More prepared for future Titanium versions (e.g. ALOY-1356)
* Cut down on [custom parsers](https://github.com/appcelerator/alloy/tree/master/Alloy/commands/compile/parsers) - in particular for proxy elements (those which map to parent properties instead of .add()
, enabling the above as well as less possible points of failure (e.g. ALOY-1282)
* Less magic and higher predictability of XML parsing for developers
* Would allow modules to use proxy elements as well, with need for Alloy to know how (like we now hard-coded ti.map
support).
How
* Drop [implicit namespaces](https://github.com/appcelerator/alloy/blob/master/Alloy/common/constants.js#L151) and always require developers to be in charge and thus conscious of which namespace or module they use vians="Ti.UI.iOS"
an module="ti.map"
.
* Replace as much proxy elements as we can by adding support for generic <Array>
and <Object>
elements, accompanied by a new parentProperty
to tell Alloy which parent property to assign it to:
<Alloy>
<Collection src="marker" />
<Map module="ti.map">
<Array parentProperty="annotations" dataCollection="marker">
<Annotation module="ti.map" />
</Array>
<Object parentProperty="region" latitude="33.74511" longitude="-84.38993" latitudeDelta="0.01" longitudeDelta="0.01" />
</Map>
</Alloy>
* Add "parentMethod" attribute for the developer to override the default add()
, which can also be used with the above:
<Alloy>
<Map module="ti.map">
<Polygon module="ti.map" parentMethod="addPolygon" />
<Array parentMethod="addAnnotations" dataCollection="marker">
<Annotation module="ti.map" />
</Array>
</Map>
</Alloy>
/cc [~fmiao] [~brentonhouse]
I like either way, but I guess
<Array parentProperty="annotations" parentMethod="addMyAnnotations">
would give us more support for property names that might not be valid xml element names.Good argument! I updated the description to use just that.