{"action":"opened","issue":{"url":"https://api.github.com/repos/canjs/canjs/issues/2417","repository_url":"https://api.github.com/repos/canjs/canjs","labels_url":"https://api.github.com/repos/canjs/canjs/issues/2417/labels{/name}","comments_url":"https://api.github.com/repos/canjs/canjs/issues/2417/comments","events_url":"https://api.github.com/repos/canjs/canjs/issues/2417/events","html_url":"https://github.com/canjs/canjs/issues/2417","id":160209386,"number":2417,"title":"jQuery modifier bug with (el) -> el.someFunction()","user":{"login":"foxdonut","id":1706600,"avatar_url":"https://avatars.githubusercontent.com/u/1706600?v=3","gravatar_id":"","url":"https://api.github.com/users/foxdonut","html_url":"https://github.com/foxdonut","followers_url":"https://api.github.com/users/foxdonut/followers","following_url":"https://api.github.com/users/foxdonut/following{/other_user}","gists_url":"https://api.github.com/users/foxdonut/gists{/gist_id}","starred_url":"https://api.github.com/users/foxdonut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foxdonut/subscriptions","organizations_url":"https://api.github.com/users/foxdonut/orgs","repos_url":"https://api.github.com/users/foxdonut/repos","events_url":"https://api.github.com/users/foxdonut/events{/privacy}","received_events_url":"https://api.github.com/users/foxdonut/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-14T15:20:10Z","updated_at":"2016-06-14T15:20:10Z","closed_at":null,"body":"Context: we are working with long-time CanJS code, around version 1.0.7 or so. Back then, it was idiomatic, or, at least, it was a practice that was not on its way out as it seems to be today, to use\r\n\r\n```\r\n<div {{(el) -> el.someFunction()}}>\r\n```\r\n\r\nNow, when `someFunction()` calls `el.html(htmlString)`, and `htmlString` does not have a single root node, such as:\r\n\r\n```html\r\nvar htmlString = '<li>One</li><li>Two</li><li>Three</li><li>Four</li>';\r\n```\r\n\r\nThen, when using `can.view.modifiers.js`, the `html` function is \"decorated\" by CanJS and the result is incorrect.\r\n\r\nHere is a code example illustrating the issue:\r\n\r\nhttp://codepen.io/foxdonut/pen/PzNXOW?editors=1010\r\n\r\nA workaround is to move the code out of `{{(el) -> el.someFunction()}}` and into the JavaScript code, such as into the `init` function.\r\n\r\nThis is a somewhat obscure issue. I also understand that the `(el) ->` syntax is on its way out, as are CanJS modifiers themselves. Nevertheless, this caused a bug in our production code. We'll be using the workaround mentioned above, but I still wanted to document this issue in case anyone else encounters similar problems. When some code calls `element.html(...)` and the result is not what you expect, it can be difficult to figure out why this is happening.\r\n"}}
{"actor":{"display_login":"foxdonut"}}