@plastic-js/plastic 1.0.7 → 1.0.9
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/package.json +2 -2
- package/src/jsx-runtime.js +14 -5
- package/src/router.js +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plastic-js/plastic",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
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.
|
|
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",
|
package/src/jsx-runtime.js
CHANGED
|
@@ -1263,6 +1263,14 @@ const insert = (parent, accessor, marker = null)=> {
|
|
|
1263
1263
|
// change. Class and style go through the existing helpers so the
|
|
1264
1264
|
// merge/diff semantics stay identical to the JSX path.
|
|
1265
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
|
+
}
|
|
1266
1274
|
// Event handlers (onClick, etc.) — the babel transform emits them as
|
|
1267
1275
|
// `() => handler` thunks. Resolve once to the handler and attach a single
|
|
1268
1276
|
// listener that re-reads the current accessor at dispatch time (so a signal
|
|
@@ -1331,12 +1339,13 @@ const setProp = (element, key, accessor)=> {
|
|
|
1331
1339
|
const renderApp = (container, node)=> {
|
|
1332
1340
|
const appNode = node2Element(node)
|
|
1333
1341
|
container.appendChild(appNode)
|
|
1334
|
-
//
|
|
1342
|
+
// Walk the full DOM subtree to find all component owners and fire their
|
|
1343
|
+
// onMount callbacks. The root node may be a native element (e.g. <div>)
|
|
1344
|
+
// which never gets an OWNER reference, but nested component outputs do.
|
|
1345
|
+
mountOwnedSubtree(appNode)
|
|
1346
|
+
|
|
1347
|
+
// Keep the root owner reference for cleanup disposal.
|
|
1335
1348
|
const owner = appNode[OWNER]
|
|
1336
|
-
// Execute root onMount callbacks if owner exists
|
|
1337
|
-
if (owner){
|
|
1338
|
-
runOwnerMounts(owner)
|
|
1339
|
-
}
|
|
1340
1349
|
|
|
1341
1350
|
// Return a disposer function
|
|
1342
1351
|
let disposed = false
|
package/src/router.js
CHANGED
|
@@ -813,6 +813,7 @@ const NavLink = ({
|
|
|
813
813
|
activeClass = 'active',
|
|
814
814
|
ariaCurrent = 'page',
|
|
815
815
|
end = false,
|
|
816
|
+
disabled = false,
|
|
816
817
|
...props
|
|
817
818
|
})=> {
|
|
818
819
|
const location = useLocation()
|
|
@@ -830,12 +831,20 @@ const NavLink = ({
|
|
|
830
831
|
})
|
|
831
832
|
const resolvedClassName = ()=> {
|
|
832
833
|
const baseClassName = typeof className === 'function' ? className() : className
|
|
833
|
-
const tokens = [baseClassName, isActive() ? activeClass : '']
|
|
834
|
+
const tokens = [baseClassName, isActive() && !disabled ? activeClass : '']
|
|
834
835
|
.filter(value=> typeof value === 'string' && value.trim())
|
|
835
836
|
.map(value=> value.trim())
|
|
836
837
|
return tokens.join(' ')
|
|
837
838
|
}
|
|
838
839
|
|
|
840
|
+
if (disabled){
|
|
841
|
+
return h('span', {
|
|
842
|
+
...props,
|
|
843
|
+
'aria-disabled': 'true',
|
|
844
|
+
className: resolvedClassName,
|
|
845
|
+
}, children)
|
|
846
|
+
}
|
|
847
|
+
|
|
839
848
|
return h(Link, {
|
|
840
849
|
...props,
|
|
841
850
|
to,
|