{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/dom/issues/461","repository_url":"https://api.github.com/repos/whatwg/dom","labels_url":"https://api.github.com/repos/whatwg/dom/issues/461/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/dom/issues/461/comments","events_url":"https://api.github.com/repos/whatwg/dom/issues/461/events","html_url":"https://github.com/whatwg/dom/issues/461","id":230460133,"node_id":"MDU6SXNzdWUyMzA0NjAxMzM=","number":461,"title":"Consider boolean interface for properties","user":{"login":"jonathanKingston","id":338988,"node_id":"MDQ6VXNlcjMzODk4OA==","avatar_url":"https://avatars3.githubusercontent.com/u/338988?v=4","gravatar_id":"","url":"https://api.github.com/users/jonathanKingston","html_url":"https://github.com/jonathanKingston","followers_url":"https://api.github.com/users/jonathanKingston/followers","following_url":"https://api.github.com/users/jonathanKingston/following{/other_user}","gists_url":"https://api.github.com/users/jonathanKingston/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanKingston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanKingston/subscriptions","organizations_url":"https://api.github.com/users/jonathanKingston/orgs","repos_url":"https://api.github.com/users/jonathanKingston/repos","events_url":"https://api.github.com/users/jonathanKingston/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanKingston/received_events","type":"User","site_admin":false},"labels":[{"id":429410107,"node_id":"MDU6TGFiZWw0Mjk0MTAxMDc=","url":"https://api.github.com/repos/whatwg/dom/labels/needs%20implementer%20interest","name":"needs implementer interest","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2017-05-22T17:05:17Z","updated_at":"2018-06-14T11:49:59Z","closed_at":null,"author_association":"NONE","body":"I often want to control boolean attributes with a property, forgetting that I have to write boiler plate to `setAttribute`/`removeAttribute` when other libraries provide convenience functions that are based upon the type or the attribute being set.\r\n\r\njQuery has two methods `attr()` and `prop()` which make managing boolean attributes much simpler:\r\n\r\n```\r\n$el.prop(\"hidden\", true); // <el hidden=\"\" />\r\n$el.prop(\"hidden\", false); // <el />\r\n```\r\n\r\nand:\r\n```\r\n$el.attr(\"hidden\", true); // <el hidden=\"hidden\" />\r\n$el.attr(\"hidden\", false); // <el />\r\n```\r\n\r\nPerhaps it doesn't make sense to implement this for all attributes, instead provide just:\r\n\r\n```\r\nel.setBoolAttribute(\"\");\r\n```\r\n\r\nWhich would function like:\r\n```\r\nElement.prototype.setBoolAttribute = function (attr, bool) {\r\n  if (bool) {\r\n    this.setAttribute(attr, \"\");\r\n  } else {\r\n    this.removeAttribute(attr);\r\n  }\r\n};\r\n```\r\n\r\nThat being said a new `el.prototype.attr()` method could implement this too, where boolean attributes to the second argument would behave different to a string:\r\n```\r\nel.attr(\"hidden\", \"false\"); // <el hidden=\"false\" />\r\nel.attr(\"hidden\", false); // <el />\r\n```"},"comment":{"url":"https://api.github.com/repos/whatwg/dom/issues/comments/397267020","html_url":"https://github.com/whatwg/dom/issues/461#issuecomment-397267020","issue_url":"https://api.github.com/repos/whatwg/dom/issues/461","id":397267020,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzI2NzAyMA==","user":{"login":"WebReflection","id":85749,"node_id":"MDQ6VXNlcjg1NzQ5","avatar_url":"https://avatars3.githubusercontent.com/u/85749?v=4","gravatar_id":"","url":"https://api.github.com/users/WebReflection","html_url":"https://github.com/WebReflection","followers_url":"https://api.github.com/users/WebReflection/followers","following_url":"https://api.github.com/users/WebReflection/following{/other_user}","gists_url":"https://api.github.com/users/WebReflection/gists{/gist_id}","starred_url":"https://api.github.com/users/WebReflection/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WebReflection/subscriptions","organizations_url":"https://api.github.com/users/WebReflection/orgs","repos_url":"https://api.github.com/users/WebReflection/repos","events_url":"https://api.github.com/users/WebReflection/events{/privacy}","received_events_url":"https://api.github.com/users/WebReflection/received_events","type":"User","site_admin":false},"created_at":"2018-06-14T11:49:59Z","updated_at":"2018-06-14T11:49:59Z","author_association":"NONE","body":"@annevk to be honest, I don't think it's super important to have that any differently, but if you create template dynamically as with _hyperHTML_ or _lit-html_ (or others) having that ability might simplify things. Worth saying I've personally solved this issue already so I actually would probably never benefit from this method, but others not using _hyperHTML_ but raw DOM might surely appreciate this new method.\r\n\r\nIf that ever happens please let me know so I can add it to my DOM4 polyfill, thanks."}}
{"actor":{"display_login":"WebReflection"}}