You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a can.Component has a define property that’s Type is a can.List, and that can.List has a Map type, and that can.Map has define properties, then those properties should be available on instances of the items within the list. For example:
var Item = can.Map.extend({
define: {
prop: {
get: function() {
return 'define prop';
}
}
}
});
var Collection = can.List.extend({
Map: Item
}, {});
var collectionInstance = new Collection([{}]);
collectionInstance[0].attr('prop');// Returns “define prop”
var homeTemplate = can.view.stache('<p>{{vmProp}}</p>');
can.Component.extend({
tag: "home-page",
template: homeTemplate,
viewModel: {
define: {
collection: {
Type: Collection
},
vmProp: {
get: function() {
var collection = this.attr('collection');
return collection[0].attr('prop') || 'no prop';
}
}
}
}
});
var appTemplate = can.view.stache('<home-page collection="{collection}" />');
$("body").html(
appTemplate({
collection: [{objectProp:'object prop'}]
})
);
// Body should have “define prop” but instead has “no prop”
…her attributes have been bound
When a component is set up, `%root` is added to the initial `viewModel` data so it’s available in every scope. However, this causes issues when the `%root` bindings are set up before all of the other properties, so this moves the setup for `%root` until after all the other properties have been bound.
Fixes#2250
If a
can.Component
has adefine
property that’sType
is acan.List
, and thatcan.List
has aMap
type, and thatcan.Map
hasdefine
properties, then those properties should be available on instances of the items within the list. For example:Works in 2.2.9 (“define prop” is output): http://jsbin.com/cocarikefo/1/edit?html,js,output
Doesn’t work with latest (“no prop” is output): http://jsbin.com/rufavacera/1/edit?html,js,output
The text was updated successfully, but these errors were encountered: