[SalesForce] How to use aura:attribute of type Object

I was playing around with lightning components, and I came across a weird situation.

Data binding for attribute type object doesn't work.

here is minimum viable code to reproduce this behavior.

<aura:application>

    <aura:attribute type="Object" name="myObject" default="{'Name':'Dummy'}"></aura:attribute>

    <lightning:input type="text" label="Name" name="myName" value="{!v.myObject.Name}" />


    Debug: 
    {!v.myObject.Name}
</aura:application>

Nothing fancy, I declared an attribute and using it in Lightning: input to check binding.(I tried with UI:InputText same issue).

According to this documentation there are issues with serialization when using attribute of type Object when doing server downtrip. As I am not doing any, it should be fine.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_attr_types_object.htm

I can change the atrribute type to Map to make it work, I want to know if its the expected behaviour for attribute of type Object or am missing something silly.

Edit: So I tried removing the default and doing initialization in init event. Same behaviour.

Best Answer

The only situation I've noticed the type attribute having an impact is in the parsing of the default value. Changing to Map or SObject will get your default parsed.

This value can't be relevant to basic JavaScript syntax by the very nature of JavaScript's weak typing. But when the .cmp is processed specific logic can be run. There may also be some type-specific logic inside the client-side Aura framework but I haven't noticed it.