@tltdsh/mx 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -124,6 +124,8 @@ __defineSetter__, __lookupGetter__, __lookupSetter__, __proto__
124
124
 
125
125
  `mx.toString()` produces a broken description that throws `InvalidCharacterError` at `createElement` time. Also applies to `define('toString', ...)`.
126
126
 
127
+ Tag/component names only - **attribute** names are safe: the reconciler tracks attrs by own-key checks (`Object.hasOwn`), so `{ toString: 'x' }` sets and removes cleanly, and attrs objects with an own `constructor` key are still recognized as attrs.
128
+
127
129
  ---
128
130
 
129
131
  ## Checklist for New Components
@@ -251,6 +253,10 @@ Caveats vs `render()`: `$attrs` cannot clear event handlers (it calls `removeAtt
251
253
 
252
254
  **Stamp system**: Event handlers set via `render()` attrs in render N but absent in render N+1 are auto-nullified. You never manually remove handlers.
253
255
 
256
+ **Custom events**: `on*` attrs only register listeners for spec-known handler properties (`onclick`, `oninput`, ...). A custom event type (`onping: fn`) is a silent expando - use `addEventListener` once (guarded) for custom events.
257
+
258
+ **Children-first ordering**: `render()` reconciles an element's children before applying its own attributes (load-bearing for `select.value`). Consequences: a child that dispatches an event synchronously during mount is missed by the parent's not-yet-attached handler, and a child reading a parent attribute during `$()` sees the previous render's value. Pass data via `$state`, dispatch after mount.
259
+
254
260
  ---
255
261
 
256
262
  ## Conditional Rendering
package/CLAUDE.md CHANGED
@@ -124,6 +124,8 @@ __defineSetter__, __lookupGetter__, __lookupSetter__, __proto__
124
124
 
125
125
  `mx.toString()` produces a broken description that throws `InvalidCharacterError` at `createElement` time. Also applies to `define('toString', ...)`.
126
126
 
127
+ Tag/component names only - **attribute** names are safe: the reconciler tracks attrs by own-key checks (`Object.hasOwn`), so `{ toString: 'x' }` sets and removes cleanly, and attrs objects with an own `constructor` key are still recognized as attrs.
128
+
127
129
  ---
128
130
 
129
131
  ## Checklist for New Components
@@ -251,6 +253,10 @@ Caveats vs `render()`: `$attrs` cannot clear event handlers (it calls `removeAtt
251
253
 
252
254
  **Stamp system**: Event handlers set via `render()` attrs in render N but absent in render N+1 are auto-nullified. You never manually remove handlers.
253
255
 
256
+ **Custom events**: `on*` attrs only register listeners for spec-known handler properties (`onclick`, `oninput`, ...). A custom event type (`onping: fn`) is a silent expando - use `addEventListener` once (guarded) for custom events.
257
+
258
+ **Children-first ordering**: `render()` reconciles an element's children before applying its own attributes (load-bearing for `select.value`). Consequences: a child that dispatches an event synchronously during mount is missed by the parent's not-yet-attached handler, and a child reading a parent attribute during `$()` sees the previous render's value. Pass data via `$state`, dispatch after mount.
259
+
254
260
  ---
255
261
 
256
262
  ## Conditional Rendering
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # mx.js
2
2
 
3
- Sub-1KB reactive DOM reconciliation engine for building massive platforms and user interfaces at scale. **765 bytes** brotli. 4 globals, zero dependencies, no virtual DOM, no build step. Small enough to fit in an AI context window.
3
+ Sub-1KB reactive DOM reconciliation engine for building massive platforms and user interfaces at scale. **Under 1KB** brotli. 4 globals, zero dependencies, no virtual DOM, no build step. Small enough to fit in an AI context window.
4
4
 
5
5
  **Full documentation & live playground: [mxjs.dev](https://mxjs.dev)**
6
6
 
@@ -21,7 +21,7 @@ Sub-1KB reactive DOM reconciliation engine for building massive platforms and us
21
21
  ### Pinned version
22
22
 
23
23
  ```html
24
- <script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.3.1/mx.min.js"></script>
24
+ <script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.3.2/mx.min.js"></script>
25
25
  ```
26
26
 
27
27
  ### npm / yarn / bun
package/mx.d.ts CHANGED
@@ -126,6 +126,12 @@ interface MxHTMLAttrs {
126
126
  'aria-owns'?: string;
127
127
  'aria-haspopup'?: boolean | 'true' | 'false' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
128
128
 
129
+ // ARIA live region cluster (accessibility)
130
+ 'aria-live'?: 'off' | 'polite' | 'assertive';
131
+ 'aria-atomic'?: boolean | 'true' | 'false';
132
+ 'aria-busy'?: boolean | 'true' | 'false';
133
+ 'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time';
134
+
129
135
  // Loading
130
136
  fetchpriority?: 'high' | 'low' | 'auto';
131
137
 
package/mx.min.js CHANGED
@@ -1 +1 @@
1
- !function(i,m,_,u){let $='http://www.w3.org/2000/svg',t={selected:1,value:1,checked:1},h={},R=i=>h[i]||=i.replace(/[A-Z]/g,'-$&').toLowerCase(),l=Object.assign,w=i=>new Proxy(i,{get:(m,_)=>i.bind(0,_)}),n=(m,t)=>!t&'svg'!=m?l(i.createElement(m),_[m]):i.createElementNS($,m);define=(m,i={})=>{if(i.$)i.$$||=i.$,i.$=function(m){let _=i.$$.call(this,l(this.$state||={},m));return this.render(..._?._?[_]:_||[])};_[R(m)]=i};_=components={},m.render=function(...l){let m=this,_=$==m.namespaceURI,i=m.firstChild;for(let $ of l){let w,R,g;if($==null|!1===$)continue;if($._)[w,R,g]=$;else if($.nodeType){i!=$&&(i?i.replaceWith($):m.append($)),i=$.nextSibling;continue}if(i)!w?i.splitText?$+''!=i.data&&(i.data=$):i.replaceWith(i=new Text($)):w!=i.localName&&i.replaceWith(i=n(w,_));else if(w)m.append(i=n(w,_));else{m.append($);continue}if(w)if(i.$)i._$=0,i.$(R);else{i.render(...g);let _=i._$||={},n=i._$$||={},l=u=-~u;for(let m in _){R&&m in R||((m[0]=='.'?t[m.slice(1)]&&delete n[m.slice(1)]:(t[m]&&(delete n[m],i[m]=''),i.R(m))),delete _[m])}for(let m in R){let $=R[m];_[m]===$?m[0]=='.'?(i[m.slice(1)]=$,n[m.slice(1)]=l):t[m]?(i[m]=$,n[m]=l):$?.call&&(n[m]=l):m[0]=='.'?(i[m.slice(1)]=$,n[m.slice(1)]=l,_[m]=$):$!=null&!1!==$?($.call?(i[m]=$,n[m]=l):(t[m]?(i[m]=$,n[m]=l):delete n[m],i.setAttribute(m,$)),_[m]=$):(t[m]&&(delete n[m],i[m]=''),i.R(m),delete _[m])}for(let m in n)l-n[m]&&(delete n[m],i[m]=null)}i=i.nextSibling}for(let m;i;i=m)m=i.nextSibling,i.remove();return this},m.R=m.removeAttribute,m.$attrs=function(i,m,$){for(m in i)$=i[m],m[0]=='.'?this[m.slice(1)]=$:$!=null&!1!==$?($.call?this[m]=$:this.setAttribute(m,$)):this.R(m);return this},mx=w((i,m,..._)=>(i=R(i),_=m?.constructor==Object&&!m?.nodeType?[i,m,_]:[i,null,[m,..._]],_._=1,_)),dom=w((i,m,..._)=>(i=n(R(i)),m?.constructor==Object&&!m?.nodeType?i.$?i.$(m):i.$attrs(m).render(..._):i.render(m,..._),i))}(document,Element.prototype)
1
+ !function(m,i,_,u){let $='http://www.w3.org/2000/svg',t={selected:1,value:1,checked:1},x=Symbol(),n=(i,t)=>!t&'svg'!=i?l(m.createElement(i),_[i]):m.createElementNS($,i),R=m=>h[m]||=m.replace(/[A-Z]/g,'-$&').toLowerCase(),h={},l=Object.assign,w=(m,n={})=>new Proxy(m,{get:(i,_)=>n[_]||=m.bind(0,_)});define=(i,m={})=>{if(m.$)m.$$||=m.$,m.$=function(i){let _=m.$$.call(this,l(this.$state||={},i));return this.render(..._?._?[_]:_||[])};_[R(i)]=m};i.render=function(...l){let i=this,_=i.namespaceURI==$&'foreignObject'!=i.localName,m=i.firstChild;for(let $ of l){let w,R,g;if($==null|!1===$)continue;if($._)[w,R,g]=$;else if($.nodeType){$!=m&&(m?m.replaceWith($):i.append($)),m=$.nextSibling;continue}if(m)!w?m.splitText?m.data!=$+''&&(m.data=$):m.replaceWith(m=new Text($)):w!=m.localName&&m.replaceWith(m=n(w,_));else if(w)i.append(m=n(w,_));else{i.append($);continue}if(w)if(m.$)m[x]=0,m.$(R);else{m.render(...g);let[_,n]=m[x]||=[{},{}],l=u=-~u;for(let i in _){R&&Object.hasOwn(R,i)||(('.'==i[0]?t[i.slice(1)]&&delete n[i.slice(1)]:(t[i]&&(delete n[i],m[i]=''),m.R(i))),delete _[i])}for(let i in R){let $=R[i];_[i]===$?'.'==i[0]?(m[i.slice(1)]=$,n[i.slice(1)]=l):t[i]?(m[i]=$,n[i]=l):$?.call&&(n[i]=l):'.'==i[0]?(m[i.slice(1)]=$,n[i.slice(1)]=l,_[i]=$):$!=null&!1!==$?($.call?(m[i]=$,n[i]=l):(t[i]?(m[i]=$,n[i]=l):delete n[i],m.setAttribute(i,$)),_[i]=$):(t[i]&&(delete n[i],m[i]=''),m.R(i),delete _[i])}for(let i in n)l-n[i]&&(delete n[i],m[i]=null)}m=m.nextSibling}for(let i;m;m=i)i=m.nextSibling,m.remove();return this},i.R=i.removeAttribute,_=components={},i.$attrs=function(m,i,$){for(i in m)$=m[i],'.'==i[0]?this[i.slice(1)]=$:$!=null&!1!==$?($.call?this[i]=$:this.setAttribute(i,$)):this.R(i);return this},mx=w((m,i,..._)=>(m=R(m),_=i?.__proto__==Object.prototype&&!i?.nodeType?[m,i,_]:[m,null,[i,..._]],_._=1,_)),dom=w((m,i,..._)=>(m=n(R(m)),i?.__proto__==Object.prototype&&!i?.nodeType?m.$?m.$(i):m.$attrs(i).render(..._):m.render(i,..._),m))}(document,Element.prototype)
package/mx.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  let mx, dom, define, components;
2
- !function(i,m,_,u){let $='http://www.w3.org/2000/svg',t={selected:1,value:1,checked:1},h={},R=i=>h[i]||=i.replace(/[A-Z]/g,'-$&').toLowerCase(),l=Object.assign,w=i=>new Proxy(i,{get:(m,_)=>i.bind(0,_)}),n=(m,t)=>!t&'svg'!=m?l(i.createElement(m),_[m]):i.createElementNS($,m);define=(m,i={})=>{if(i.$)i.$$||=i.$,i.$=function(m){let _=i.$$.call(this,l(this.$state||={},m));return this.render(..._?._?[_]:_||[])};_[R(m)]=i};_=components={},m.render=function(...l){let m=this,_=$==m.namespaceURI,i=m.firstChild;for(let $ of l){let w,R,g;if($==null|!1===$)continue;if($._)[w,R,g]=$;else if($.nodeType){i!=$&&(i?i.replaceWith($):m.append($)),i=$.nextSibling;continue}if(i)!w?i.splitText?$+''!=i.data&&(i.data=$):i.replaceWith(i=new Text($)):w!=i.localName&&i.replaceWith(i=n(w,_));else if(w)m.append(i=n(w,_));else{m.append($);continue}if(w)if(i.$)i._$=0,i.$(R);else{i.render(...g);let _=i._$||={},n=i._$$||={},l=u=-~u;for(let m in _){R&&m in R||((m[0]=='.'?t[m.slice(1)]&&delete n[m.slice(1)]:(t[m]&&(delete n[m],i[m]=''),i.R(m))),delete _[m])}for(let m in R){let $=R[m];_[m]===$?m[0]=='.'?(i[m.slice(1)]=$,n[m.slice(1)]=l):t[m]?(i[m]=$,n[m]=l):$?.call&&(n[m]=l):m[0]=='.'?(i[m.slice(1)]=$,n[m.slice(1)]=l,_[m]=$):$!=null&!1!==$?($.call?(i[m]=$,n[m]=l):(t[m]?(i[m]=$,n[m]=l):delete n[m],i.setAttribute(m,$)),_[m]=$):(t[m]&&(delete n[m],i[m]=''),i.R(m),delete _[m])}for(let m in n)l-n[m]&&(delete n[m],i[m]=null)}i=i.nextSibling}for(let m;i;i=m)m=i.nextSibling,i.remove();return this},m.R=m.removeAttribute,m.$attrs=function(i,m,$){for(m in i)$=i[m],m[0]=='.'?this[m.slice(1)]=$:$!=null&!1!==$?($.call?this[m]=$:this.setAttribute(m,$)):this.R(m);return this},mx=w((i,m,..._)=>(i=R(i),_=m?.constructor==Object&&!m?.nodeType?[i,m,_]:[i,null,[m,..._]],_._=1,_)),dom=w((i,m,..._)=>(i=n(R(i)),m?.constructor==Object&&!m?.nodeType?i.$?i.$(m):i.$attrs(m).render(..._):i.render(m,..._),i))}(document,Element.prototype)
2
+ !function(m,i,_,u){let $='http://www.w3.org/2000/svg',t={selected:1,value:1,checked:1},x=Symbol(),n=(i,t)=>!t&'svg'!=i?l(m.createElement(i),_[i]):m.createElementNS($,i),R=m=>h[m]||=m.replace(/[A-Z]/g,'-$&').toLowerCase(),h={},l=Object.assign,w=(m,n={})=>new Proxy(m,{get:(i,_)=>n[_]||=m.bind(0,_)});define=(i,m={})=>{if(m.$)m.$$||=m.$,m.$=function(i){let _=m.$$.call(this,l(this.$state||={},i));return this.render(..._?._?[_]:_||[])};_[R(i)]=m};i.render=function(...l){let i=this,_=i.namespaceURI==$&'foreignObject'!=i.localName,m=i.firstChild;for(let $ of l){let w,R,g;if($==null|!1===$)continue;if($._)[w,R,g]=$;else if($.nodeType){$!=m&&(m?m.replaceWith($):i.append($)),m=$.nextSibling;continue}if(m)!w?m.splitText?m.data!=$+''&&(m.data=$):m.replaceWith(m=new Text($)):w!=m.localName&&m.replaceWith(m=n(w,_));else if(w)i.append(m=n(w,_));else{i.append($);continue}if(w)if(m.$)m[x]=0,m.$(R);else{m.render(...g);let[_,n]=m[x]||=[{},{}],l=u=-~u;for(let i in _){R&&Object.hasOwn(R,i)||(('.'==i[0]?t[i.slice(1)]&&delete n[i.slice(1)]:(t[i]&&(delete n[i],m[i]=''),m.R(i))),delete _[i])}for(let i in R){let $=R[i];_[i]===$?'.'==i[0]?(m[i.slice(1)]=$,n[i.slice(1)]=l):t[i]?(m[i]=$,n[i]=l):$?.call&&(n[i]=l):'.'==i[0]?(m[i.slice(1)]=$,n[i.slice(1)]=l,_[i]=$):$!=null&!1!==$?($.call?(m[i]=$,n[i]=l):(t[i]?(m[i]=$,n[i]=l):delete n[i],m.setAttribute(i,$)),_[i]=$):(t[i]&&(delete n[i],m[i]=''),m.R(i),delete _[i])}for(let i in n)l-n[i]&&(delete n[i],m[i]=null)}m=m.nextSibling}for(let i;m;m=i)i=m.nextSibling,m.remove();return this},i.R=i.removeAttribute,_=components={},i.$attrs=function(m,i,$){for(i in m)$=m[i],'.'==i[0]?this[i.slice(1)]=$:$!=null&!1!==$?($.call?this[i]=$:this.setAttribute(i,$)):this.R(i);return this},mx=w((m,i,..._)=>(m=R(m),_=i?.__proto__==Object.prototype&&!i?.nodeType?[m,i,_]:[m,null,[i,..._]],_._=1,_)),dom=w((m,i,..._)=>(m=n(R(m)),i?.__proto__==Object.prototype&&!i?.nodeType?m.$?m.$(i):m.$attrs(i).render(..._):m.render(i,..._),m))}(document,Element.prototype)
3
3
  export { mx, dom, define, components };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tltdsh/mx",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "<1KB UI engine. Build big. Ship small. Iterate fast.",
5
5
  "license": "0BSD",
6
6
  "author": "tltdsh",