Skip to content

Commit

Permalink
custom element simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentpayot committed Apr 14, 2023
1 parent 58c62a7 commit ef6e2f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions minidenticons.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@ export const identiconSvg =
static observedAttributes = ['username', 'saturation', 'lightness']
// private fields to allow Terser mangling
static #memoized = {}
#isConnected = false
connectedCallback() {
this.#setContent()
this.#isConnected = true
}
connectedCallback() { this.#setContent() }
// attributeChangedCallback() is called for every observed attribute before connectedCallback()
attributeChangedCallback() { if (this.#isConnected) this.#setContent() }
attributeChangedCallback(name, oldValue) { if (oldValue !== null) this.#setContent() }
#setContent() {
const args = IdenticonSvg.observedAttributes
.map(key => this.getAttribute(key) || undefined)
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 ef6e2f4

Please sign in to comment.