{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/236","repository_url":"https://api.github.com/repos/tc39/proposal-class-fields","labels_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/236/labels{/name}","comments_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/236/comments","events_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/236/events","html_url":"https://github.com/tc39/proposal-class-fields/issues/236","id":438055488,"node_id":"MDU6SXNzdWU0MzgwNTU0ODg=","number":236,"title":"Dynamic private field access without decorators?","user":{"login":"xlaywan","id":9087446,"node_id":"MDQ6VXNlcjkwODc0NDY=","avatar_url":"https://avatars2.githubusercontent.com/u/9087446?v=4","gravatar_id":"","url":"https://api.github.com/users/xlaywan","html_url":"https://github.com/xlaywan","followers_url":"https://api.github.com/users/xlaywan/followers","following_url":"https://api.github.com/users/xlaywan/following{/other_user}","gists_url":"https://api.github.com/users/xlaywan/gists{/gist_id}","starred_url":"https://api.github.com/users/xlaywan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xlaywan/subscriptions","organizations_url":"https://api.github.com/users/xlaywan/orgs","repos_url":"https://api.github.com/users/xlaywan/repos","events_url":"https://api.github.com/users/xlaywan/events{/privacy}","received_events_url":"https://api.github.com/users/xlaywan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-04-28T13:15:01Z","updated_at":"2019-04-28T14:59:08Z","closed_at":null,"author_association":"NONE","body":"At the moment, private fields are supported in Chrome 74, but how I can use them in custom elements with declarative html templates?\r\n\r\nFor example I have custom element with declarative HTML template:\r\n```html\r\n<div>Hello, {{planet}}!</div>\r\n<div>Hey, {{#person}}!</div>\r\n```\r\n\r\nand JS class:\r\n```js\r\nclass MyEl extends HTMLElement {\r\n  planet = 'Pluto'\r\n  #person = 'John'\r\n\r\n  render() {\r\n    let props = this.template.getBindings() // ['planet', '#person']\r\n    let state = {}\r\n    props.forEach(prop => {\r\n      if (prop.startsWith('#')) {\r\n        // here we can access private property by this.#planet\r\n        // but we can't do it dynamically like this.['#planet'] or Reflect.get(...)\r\n        state[prop] = ???\r\n      } else {\r\n        state[prop] = this[prop]\r\n      }\r\n    }\r\n    this.template.update(state)\r\n  }\r\n}\r\n```\r\n\r\nHere https://github.com/tc39/proposal-class-fields/issues/204 is probably a solution with decorators. But decorators are far from shipping and it brings a boilerplate code, because we need to decorate every private field.\r\n\r\nRelated to [HTML Template Instantiation](https://github.com/w3c/webcomponents/blob/gh-pages/proposals/Template-Instantiation.md)"},"comment":{"url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/comments/487386944","html_url":"https://github.com/tc39/proposal-class-fields/issues/236#issuecomment-487386944","issue_url":"https://api.github.com/repos/tc39/proposal-class-fields/issues/236","id":487386944,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4NzM4Njk0NA==","user":{"login":"ljharb","id":45469,"node_id":"MDQ6VXNlcjQ1NDY5","avatar_url":"https://avatars1.githubusercontent.com/u/45469?v=4","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"created_at":"2019-04-28T14:59:08Z","updated_at":"2019-04-28T14:59:08Z","author_association":"MEMBER","body":"What would be the value of a field that a user-supplied template could access being private?"}}
{"actor":{"display_login":"ljharb"}}