{"action":"created","issue":{"url":"https://api.github.com/repos/lhorie/mithril.js/issues/510","labels_url":"https://api.github.com/repos/lhorie/mithril.js/issues/510/labels{/name}","comments_url":"https://api.github.com/repos/lhorie/mithril.js/issues/510/comments","events_url":"https://api.github.com/repos/lhorie/mithril.js/issues/510/events","html_url":"https://github.com/lhorie/mithril.js/issues/510","id":63629720,"number":510,"title":"components: Problems with nesting components","user":{"login":"sloria","id":2379650,"avatar_url":"https://avatars.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-03-23T05:34:21Z","updated_at":"2015-03-25T09:40:02Z","closed_at":"2015-03-25T02:18:51Z","body":"I've been trying out the new \"modules-as-components\" API on the `components` branch and ran into a snag: one cannot nest components past a depth of one. This is due to the constraint that components *must* return a virtual element--returning a module is not allowed.\r\n\r\nExample breaking code:\r\n\r\n```js\r\nvar Panel = {\r\n    view: function(ctrl, args, children) {\r\n        return m('.mypanel', [\r\n            m('.mypanel-header', [args.header], children)\r\n        ]);\r\n    }\r\n};\r\n\r\nvar Menu = {\r\n    view: function(ctrl, args) {\r\n        return m.module(Panel, {header: 'My Menu'});\r\n    }\r\n};\r\n\r\nvar Page = {\r\n    view: function(ctrl, args) {\r\n        // Crashes because Menu.view returns a module\r\n        return [\r\n            m.module(Menu, {})\r\n        ];\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/lhorie/mithril.js/issues/comments/85957543","html_url":"https://github.com/lhorie/mithril.js/issues/510#issuecomment-85957543","issue_url":"https://api.github.com/repos/lhorie/mithril.js/issues/510","id":85957543,"user":{"login":"barneycarroll","id":83627,"avatar_url":"https://avatars.githubusercontent.com/u/83627?v=3","gravatar_id":"","url":"https://api.github.com/users/barneycarroll","html_url":"https://github.com/barneycarroll","followers_url":"https://api.github.com/users/barneycarroll/followers","following_url":"https://api.github.com/users/barneycarroll/following{/other_user}","gists_url":"https://api.github.com/users/barneycarroll/gists{/gist_id}","starred_url":"https://api.github.com/users/barneycarroll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barneycarroll/subscriptions","organizations_url":"https://api.github.com/users/barneycarroll/orgs","repos_url":"https://api.github.com/users/barneycarroll/repos","events_url":"https://api.github.com/users/barneycarroll/events{/privacy}","received_events_url":"https://api.github.com/users/barneycarroll/received_events","type":"User","site_admin":false},"created_at":"2015-03-25T09:40:02Z","updated_at":"2015-03-25T09:40:02Z","body":"Was going to mention this secondary problem (persisting a component identity after moving it to another DOM island / parent component) in #514.\r\n\r\n@lhorie could you elaborate on what the identification heuristics are doing under the hood to allow this? On the face of it it would seem that whatever logic allows the component to persist between hierarchical contexts is at odds with the notion that component identities are managed based on key / index only within any given parent node. I'm having difficulty seeing how the user could specify which of these behaviours they want."}}