{"action":"created","issue":{"url":"https://api.github.com/repos/riot/riot/issues/782","labels_url":"https://api.github.com/repos/riot/riot/issues/782/labels{/name}","comments_url":"https://api.github.com/repos/riot/riot/issues/782/comments","events_url":"https://api.github.com/repos/riot/riot/issues/782/events","html_url":"https://github.com/riot/riot/issues/782","id":80894050,"number":782,"title":"Bug in server side rendering - custom tags that follow 'each' loops accidentally get included in the loop","user":{"login":"Avnerus","id":39962,"avatar_url":"https://avatars.githubusercontent.com/u/39962?v=3","gravatar_id":"","url":"https://api.github.com/users/Avnerus","html_url":"https://github.com/Avnerus","followers_url":"https://api.github.com/users/Avnerus/followers","following_url":"https://api.github.com/users/Avnerus/following{/other_user}","gists_url":"https://api.github.com/users/Avnerus/gists{/gist_id}","starred_url":"https://api.github.com/users/Avnerus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avnerus/subscriptions","organizations_url":"https://api.github.com/users/Avnerus/orgs","repos_url":"https://api.github.com/users/Avnerus/repos","events_url":"https://api.github.com/users/Avnerus/events{/privacy}","received_events_url":"https://api.github.com/users/Avnerus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/riot/riot/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/riot/riot/labels/to%20verify","name":"to verify","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-05-26T10:10:21Z","updated_at":"2015-06-23T12:40:17Z","closed_at":null,"body":"Hi,\r\nThis sounds a bit complicated, but I was able to reproduce it in my riot-isomorphic example. \r\nI've created a branch for that here: \r\nhttps://github.com/ListnPlay/riot-isomorphic/tree/each-bug\r\nIt seems that if an ```each``` loop is followed by a custom tag, the custom tag somehow gets included into the loop processing and gets mounted once for each item in the loop (**Even though the loop tag was closed**).  These mounts also send bad ```opts``` values because the ```this``` context becomes the one of the ```each``` loop which is not what the programmer intended. \r\nAlso, if you 'protect' the each loop by wrapping it with a ```<div>```, the problem does not occur.\r\nI'm not sure why but it seems to happen only in server side rendering. The server side log shows:\r\n\r\n```\r\nInit test tag with opts  { message: 'LOOP PROTECTED BY DIV' }\r\nInit test tag with opts  { message: 'LOOP NOT PROTECTED BY DIV' }\r\nInit test tag with opts  { message: undefined }\r\nInit test tag with opts  { message: undefined }\r\nInit test tag with opts  { message: undefined }\r\n```\r\nThe 3 ```undefined``` ones are for each mount of the unprotected custom tag.\r\n\r\nHowever the client side log shows:\r\n```\r\nInit test tag with opts Object { message=\"LOOP PROTECTED BY DIV\"}\r\nInit test tag with opts Object { message=\"LOOP NOT PROTECTED BY DIV\"}\r\n````\r\nWhich is the expected result.\r\nI hope this makes sense..!\r\nThanks"},"comment":{"url":"https://api.github.com/repos/riot/riot/issues/comments/114480594","html_url":"https://github.com/riot/riot/issues/782#issuecomment-114480594","issue_url":"https://api.github.com/repos/riot/riot/issues/782","id":114480594,"user":{"login":"Avnerus","id":39962,"avatar_url":"https://avatars.githubusercontent.com/u/39962?v=3","gravatar_id":"","url":"https://api.github.com/users/Avnerus","html_url":"https://github.com/Avnerus","followers_url":"https://api.github.com/users/Avnerus/followers","following_url":"https://api.github.com/users/Avnerus/following{/other_user}","gists_url":"https://api.github.com/users/Avnerus/gists{/gist_id}","starred_url":"https://api.github.com/users/Avnerus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avnerus/subscriptions","organizations_url":"https://api.github.com/users/Avnerus/orgs","repos_url":"https://api.github.com/users/Avnerus/repos","events_url":"https://api.github.com/users/Avnerus/events{/privacy}","received_events_url":"https://api.github.com/users/Avnerus/received_events","type":"User","site_admin":false},"created_at":"2015-06-23T12:40:17Z","updated_at":"2015-06-23T12:40:17Z","body":"@speier you are rendering only the inner ```<test>``` tag instead of the parent ```<each-custom>``` tag.\r\nReplace this line:\r\n```\r\nvar html = riot.render(tag)\r\n```\r\nwith this line:\r\n```\r\nvar html = riot.render('each-custom')\r\n```\r\nThen you will get this output:\r\n```\r\nTest tag init!! { message: 'LOOP PROTECTED BY DIV' }\r\nTest tag init!! { message: 'LOOP NOT PROTECTED BY DIV' }\r\nTest tag init!! { message: undefined }\r\nTest tag init!! { message: undefined }\r\nTest tag init!! { message: undefined }\r\nTest tag mounted!! { message: 'LOOP PROTECTED BY DIV' }\r\nTest tag mounted!! { message: 'LOOP NOT PROTECTED BY DIV' }\r\nTest tag mounted!! { message: undefined }\r\nTest tag mounted!! { message: undefined }\r\nTest tag mounted!! { message: undefined }\r\n```\r\n"}}