diff --git a/CHANGELOG.md b/CHANGELOG.md index 2272f23..6cf5191 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Minidenticons changelog +## 3.1.2 + +_2023-04-14_ + +### New features + +- Reverted to v3.1.0 (custom element size optimization was canceling v3 performance gain) + ## 3.1.1 _2023-04-14_ diff --git a/README.md b/README.md index 49df9e2..e3ded2a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Minidenticons uses [ES modules](https://jakearchibald.com/2017/es-modules-in-bro ```html ``` diff --git a/minidenticons.js b/minidenticons.js index 9fe3c24..46a85a2 100644 --- a/minidenticons.js +++ b/minidenticons.js @@ -47,11 +47,13 @@ export const identiconSvg = static observedAttributes = ['username', 'saturation', 'lightness'] // private fields to allow Terser mangling static #memoized = {} - connectedCallback() { this.#setContent() } - // attributeChangedCallback() is called for every observed attribute before connectedCallback() - attributeChangedCallback(name, oldValue, newValue) { - if (oldValue !== newValue) this.#setContent() + #isConnected = false + connectedCallback() { + this.#setContent() + this.#isConnected = true } + // attributeChangedCallback() is called for every observed attribute before connectedCallback() + attributeChangedCallback() { if (this.#isConnected) this.#setContent() } #setContent() { const args = IdenticonSvg.observedAttributes .map(key => this.getAttribute(key) || undefined) diff --git a/minidenticons.min.js b/minidenticons.min.js index eada3ac..9ebb8a7 100644 --- a/minidenticons.min.js +++ b/minidenticons.min.js @@ -1 +1 @@ -const t=16777619;export function identicon(e="",n=50,s=50){const i=e.split("").reduce(((e,n)=>((e^n.charCodeAt(0))>>>0)*t),2166136261);const o=i/t%12*30;return[...Array(e?25:0)].reduce(((t,e,n)=>i%(16-n%15)<4?t+``:t),``)+""}export const identiconSvg=globalThis.customElements?.define("identicon-svg",class t extends HTMLElement{static observedAttributes=["username","saturation","lightness"];static#t={};connectedCallback(){this.#e()}attributeChangedCallback(t,e,n){e!==n&&this.#e()}#e(){const e=t.observedAttributes.map((t=>this.getAttribute(t)||void 0)),n=e.join(",");this.innerHTML=t.#t[n]??=identicon(...e)}}); \ No newline at end of file +const t=16777619;export function identicon(e="",n=50,s=50){const i=e.split("").reduce(((e,n)=>((e^n.charCodeAt(0))>>>0)*t),2166136261);const o=i/t%12*30;return[...Array(e?25:0)].reduce(((t,e,n)=>i%(16-n%15)<4?t+``:t),``)+""}export const identiconSvg=globalThis.customElements?.define("identicon-svg",class t extends HTMLElement{static observedAttributes=["username","saturation","lightness"];static#t={};#e=!1;connectedCallback(){this.#n(),this.#e=!0}attributeChangedCallback(){this.#e&&this.#n()}#n(){const e=t.observedAttributes.map((t=>this.getAttribute(t)||void 0)),n=e.join(",");this.innerHTML=t.#t[n]??=identicon(...e)}}); \ No newline at end of file diff --git a/minidenticons.min.js.map b/minidenticons.min.js.map index ca546c3..713b3ef 100644 --- a/minidenticons.min.js.map +++ b/minidenticons.min.js.map @@ -1 +1 @@ -{"version":3,"names":["FNV_PRIME","identicon","username","saturation","lightness","hash","split","reduce","char","charCodeAt","hue","Array","acc","e","i","identiconSvg","globalThis","customElements","define","IdenticonSvg","HTMLElement","static","connectedCallback","this","setContent","attributeChangedCallback","name","oldValue","newValue","args","observedAttributes","map","key","getAttribute","undefined","memoKey","join","innerHTML","memoized"],"sources":["minidenticons.js"],"mappings":"AACA,MAOMA,EAAY,gBAgBX,SAASC,UAAUC,EAAS,GAAIC,EApBZ,GAoB2CC,EAnB5C,IAoBtB,MAAMC,EAAkBH,EATbI,MAAM,IAEZC,QAAO,CAACF,EAAMG,MAAWH,EAAOG,EAAKC,WAAW,MAAQ,GAAKT,GATjD,YAkBjB,MAAMU,EAAQL,EAAOL,EAxBP,GAwBiC,GAC/C,MAAO,IAAIW,MAAMT,EAAW,GAAK,IAAIK,QAAO,CAACK,EAAKC,EAAGC,IAEjDT,GAAQ,GAAKS,EAAI,IA7BF,EA8BXF,EAAM,YAAYE,EAAI,GAAK,KAAOA,EAAI,MAAQA,EAAI,UAAUA,EAAI,4BAClEF,GAEF,6EAA6EF,KAAOP,MAAeC,SAErG,QACN,QAKO,MAAMW,aAEIC,WAAWC,gBAAgBC,OAAO,gBAC3C,MAAMC,UAAqBC,YACvBC,0BAA4B,CAAC,WAAY,aAAc,aAEvDA,SAAmB,CAAC,EACpBC,oBAAsBC,MAAKC,GAAc,CAEzCC,yBAAyBC,EAAMC,EAAUC,GACjCD,IAAaC,GAAUL,MAAKC,GACpC,CACAA,KACI,MAAMK,EAAOV,EAAaW,mBACTC,KAAIC,GAAOT,KAAKU,aAAaD,SAAQE,IAChDC,EAAUN,EAAKO,KAAK,KAC1Bb,KAAKc,UAAYlB,GAAamB,EAAUH,KAEpClC,aAAa4B,EACrB"} \ No newline at end of file +{"version":3,"names":["FNV_PRIME","identicon","username","saturation","lightness","hash","split","reduce","char","charCodeAt","hue","Array","acc","e","i","identiconSvg","globalThis","customElements","define","IdenticonSvg","HTMLElement","static","isConnected","connectedCallback","this","setContent","attributeChangedCallback","args","observedAttributes","map","key","getAttribute","undefined","memoKey","join","innerHTML","memoized"],"sources":["minidenticons.js"],"mappings":"AACA,MAOMA,EAAY,gBAgBX,SAASC,UAAUC,EAAS,GAAIC,EApBZ,GAoB2CC,EAnB5C,IAoBtB,MAAMC,EAAkBH,EATbI,MAAM,IAEZC,QAAO,CAACF,EAAMG,MAAWH,EAAOG,EAAKC,WAAW,MAAQ,GAAKT,GATjD,YAkBjB,MAAMU,EAAQL,EAAOL,EAxBP,GAwBiC,GAC/C,MAAO,IAAIW,MAAMT,EAAW,GAAK,IAAIK,QAAO,CAACK,EAAKC,EAAGC,IAEjDT,GAAQ,GAAKS,EAAI,IA7BF,EA8BXF,EAAM,YAAYE,EAAI,GAAK,KAAOA,EAAI,MAAQA,EAAI,UAAUA,EAAI,4BAClEF,GAEF,6EAA6EF,KAAOP,MAAeC,SAErG,QACN,QAKO,MAAMW,aAEIC,WAAWC,gBAAgBC,OAAO,gBAC3C,MAAMC,UAAqBC,YACvBC,0BAA4B,CAAC,WAAY,aAAc,aAEvDA,SAAmB,CAAC,EACpBC,IAAe,EACfC,oBACIC,MAAKC,IACLD,MAAKF,GAAe,CACxB,CAEAI,2BAAiCF,MAAKF,GAAcE,MAAKC,GAAc,CACvEA,KACI,MAAME,EAAOR,EAAaS,mBACTC,KAAIC,GAAON,KAAKO,aAAaD,SAAQE,IAChDC,EAAUN,EAAKO,KAAK,KAC1BV,KAAKW,UAAYhB,GAAaiB,EAAUH,KAEpChC,aAAa0B,EACrB"} \ No newline at end of file diff --git a/package.json b/package.json index 04bd4b6..00fc0bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minidenticons", - "version": "3.1.1", + "version": "3.1.2", "description": "Super lightweight SVG identicon (icon avatar) generator", "author": "Laurent Payot", "license": "MIT",