Open thescientist13 opened 6 years ago
If managing attributes by hand, often times it requires doing something like this
class MyComponent extends HTMLElement { constructor() { super(); this._foo = []; this.root = this.attachShadow({ mode: 'closed' }); } static get observedAttributes() { return ['foo']; } attributeChangedCallback(name, oldVal, newVal) { switch (name) { case 'foo': this._foor = newVal ? JSON.parse(newVal) : []; break; default: } } /* code */ }
This can be helpful to avoid reflection of properties and attributes on the same value by prefixing with the _ but it is really only faux privacy. Having real privacy would be nice. 👍
_
Shipping in Chrome! 😮 https://twitter.com/mathias/status/1121395767170740225
cc: @hutchgrant
If managing attributes by hand, often times it requires doing something like this
This can be helpful to avoid reflection of properties and attributes on the same value by prefixing with the
_
but it is really only faux privacy. Having real privacy would be nice. 👍