Skip to content

Commit

Permalink
custom element private fields for Terser mangling
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentpayot committed Apr 10, 2023
1 parent cb3d34b commit 4cec337
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions minidenticons.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ export const identiconSvg =
/*@__PURE__*/globalThis.customElements?.define('identicon-svg',
class IdenticonSvg extends HTMLElement {
static observedAttributes = ['username', 'saturation', 'lightness']
static memo = {}
static #memo = {}
#isConnected = false
connectedCallback() {
this.identiconSvg()
this.#identiconSvg()
this.#isConnected = true
}
// attributeChangedCallback() is called for every observed attribute before connectedCallback()
attributeChangedCallback() { if (this.#isConnected) this.identiconSvg() }
identiconSvg() {
attributeChangedCallback() { if (this.#isConnected) this.#identiconSvg() }
#identiconSvg() {
const args = IdenticonSvg.observedAttributes
.map(key => this.getAttribute(key) || undefined)
const memoKey = args.join(',')
this.innerHTML = IdenticonSvg.memo[memoKey] ??=
this.innerHTML = IdenticonSvg.#memo[memoKey] ??=
// @ts-ignore
identicon(...args)
}
Expand Down
2 changes: 1 addition & 1 deletion minidenticons.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion minidenticons.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4cec337

Please sign in to comment.