@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 +6 -0
- package/CLAUDE.md +6 -0
- package/README.md +2 -2
- package/mx.d.ts +6 -0
- package/mx.min.js +1 -1
- package/mx.mjs +1 -1
- package/package.json +1 -1
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. **
|
|
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.
|
|
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,
|
|
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,
|
|
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 };
|