{"action":"opened","issue":{"url":"https://api.github.com/repos/strophe/strophejs/issues/124","labels_url":"https://api.github.com/repos/strophe/strophejs/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/strophe/strophejs/issues/124/comments","events_url":"https://api.github.com/repos/strophe/strophejs/issues/124/events","html_url":"https://github.com/strophe/strophejs/issues/124","id":87561691,"number":124,"title":"Strophe.Builder.c will swallow elements if given a blank string as a 'text' parameter","user":{"login":"notnarb","id":1731591,"avatar_url":"https://avatars.githubusercontent.com/u/1731591?v=3","gravatar_id":"","url":"https://api.github.com/users/notnarb","html_url":"https://github.com/notnarb","followers_url":"https://api.github.com/users/notnarb/followers","following_url":"https://api.github.com/users/notnarb/following{/other_user}","gists_url":"https://api.github.com/users/notnarb/gists{/gist_id}","starred_url":"https://api.github.com/users/notnarb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/notnarb/subscriptions","organizations_url":"https://api.github.com/users/notnarb/orgs","repos_url":"https://api.github.com/users/notnarb/repos","events_url":"https://api.github.com/users/notnarb/events{/privacy}","received_events_url":"https://api.github.com/users/notnarb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-12T01:02:25Z","updated_at":"2015-06-12T01:02:25Z","closed_at":null,"body":"https://github.com/strophe/strophejs/blob/v1.2.1/src/core.js#L1121\r\nThis seems like odd behavior to me:\r\n```\r\n     *  This function moves the current element pointer to the child,\r\n     *  unless text is provided.  If you need to add another child, it\r\n     *  is necessary to use up() to go back to the parent in the tree.\r\n```\r\nis clearly specified but the code to check if 'text is provided' is\r\n```javascript\r\nif (!text) {\r\n  this.node = child;\r\n}\r\n```\r\n---\r\nAn example of how this might be an issue is if you were setting your presence like\r\n```javascript\r\n$pres.c('show', {}, var1)\r\n    .c('status', {}, var2)\r\n```\r\nIf var1 and var2 were blank (for example, if they were entered by a user), I would expect the following behavior\r\n```xml\r\n<presence>\r\n  <show/>\r\n  <status/>\r\n</presence/>\r\n```\r\nbut what happens instead is\r\n```xml\r\n<presence>\r\n  <show>\r\n    <status/>\r\n  </show>\r\n</presence>\r\n```\r\nbecause \"\" is falsey.\r\n\r\n---\r\nI would expect false or undefined to trigger the current behavior, but I don't think a blank string might be intentional.  I think either the documentation should be changed (e.g. \"moves the element pointer to the child if text is falsey (including an empty string)\") or an explicit check for the empty string should be added to the code.\r\n\r\nMy current workaround is \r\n```javascript\r\n$pres().c('show',{},couldBeEmpty || true)\r\n```\r\nwhich makes an empty node that does not become the parent of subsequent nodes."}}