@plastic-js/plastic 1.0.6 → 1.0.8

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/jsx-runtime.js +15 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plastic-js/plastic",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "main": "src/index.js",
5
5
  "access": "public",
6
6
  "sideEffects": false,
@@ -60,7 +60,7 @@
60
60
  "@testing-library/jest-dom": "^6.9.1",
61
61
  "@vitejs/plugin-react": "^6.0.2",
62
62
  "@vitejs/plugin-vue": "^6.0.7",
63
- "@plastic-js/babel-preset-plastic": "^0.1.7",
63
+ "@plastic-js/babel-preset-plastic": "^0.1.8",
64
64
  "eslint": "^9.39.2",
65
65
  "eslint-config-janus": "^9.0.21",
66
66
  "eslint-plugin-mocha": "^11.3.0",
@@ -758,8 +758,14 @@ const applyProps = (element, props = {})=> {
758
758
  // owner rather than the outer effect's per-run cleanup list. Otherwise
759
759
  // flushCleanups on the next outer re-run would tear down listeners for
760
760
  // keys we intend to keep.
761
+ // Also clear alien-signals' activeSub so each per-key inner effect is
762
+ // a root effect, not a child of the outer key-tracking effect — child
763
+ // effects get auto-disposed when the parent re-runs, which would kill
764
+ // surviving keys' bindings.
761
765
  const prevComp = getCurrentComputation()
766
+ const prevSub = getActiveSub()
762
767
  setCurrentComputation(null)
768
+ setActiveSub(undefined)
763
769
  try {
764
770
  if (key === 'ref'){
765
771
  const ref = props[key]
@@ -776,6 +782,7 @@ const applyProps = (element, props = {})=> {
776
782
  return bindReactiveProp(element, props, key, propsIsTracked)
777
783
  } finally {
778
784
  setCurrentComputation(prevComp)
785
+ setActiveSub(prevSub)
779
786
  }
780
787
  }
781
788
 
@@ -1256,6 +1263,14 @@ const insert = (parent, accessor, marker = null)=> {
1256
1263
  // change. Class and style go through the existing helpers so the
1257
1264
  // merge/diff semantics stay identical to the JSX path.
1258
1265
  const setProp = (element, key, accessor)=> {
1266
+ if (key === 'ref'){
1267
+ // babel-preset-plastic's template fast path always emits refs as
1268
+ // `() => refCallback` thunks — unwrap once. Calling the accessor as
1269
+ // a probe would invoke a direct callback with undefined, so we don't.
1270
+ const ref = typeof accessor === 'function' ? accessor() : accessor
1271
+ applyRefProp(element, ref)
1272
+ return
1273
+ }
1259
1274
  // Event handlers (onClick, etc.) — the babel transform emits them as
1260
1275
  // `() => handler` thunks. Resolve once to the handler and attach a single
1261
1276
  // listener that re-reads the current accessor at dispatch time (so a signal