@srfnstack/fntags 1.1.0 → 1.1.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/package.json +1 -1
- package/src/fntags.mjs +5 -5
package/package.json
CHANGED
package/src/fntags.mjs
CHANGED
|
@@ -267,25 +267,25 @@ function doBindSelectAttr (attribute) {
|
|
|
267
267
|
const attrFn = (attribute && !attribute.isFnState && typeof attribute === 'function')
|
|
268
268
|
? (...args) => attribute(args.length > 0 ? args[0] : ctx.selected)
|
|
269
269
|
: attribute
|
|
270
|
-
const boundAttr = createBoundAttr(attrFn)
|
|
270
|
+
const boundAttr = createBoundAttr(attrFn, this)
|
|
271
271
|
boundAttr.init = (attrName, element) =>
|
|
272
272
|
subscribeSelect(ctx, (selectedKey) => setAttribute(attrName, attribute.isFnState ? attribute() : attribute(selectedKey), element))
|
|
273
273
|
return boundAttr
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
function createBoundAttr (attr) {
|
|
276
|
+
function createBoundAttr (attr, state) {
|
|
277
277
|
if (typeof attr !== 'function') {
|
|
278
278
|
throw new Error('You must pass a function to bindAttr')
|
|
279
279
|
}
|
|
280
280
|
// wrap the function to avoid modifying it
|
|
281
|
-
const boundAttr = () => attr()
|
|
281
|
+
const boundAttr = () => attr(state())
|
|
282
282
|
boundAttr.isBoundAttribute = true
|
|
283
283
|
return boundAttr
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
function doBindAttr (attribute) {
|
|
287
287
|
attribute = attribute ?? this
|
|
288
|
-
const boundAttr = createBoundAttr(attribute)
|
|
288
|
+
const boundAttr = createBoundAttr(attribute, this)
|
|
289
289
|
boundAttr.init = (attrName, element) => {
|
|
290
290
|
setAttribute(attrName, attribute.isFnState ? attribute() : attribute(this()), element)
|
|
291
291
|
this.subscribe((newState, oldState) => setAttribute(attrName, attribute.isFnState ? attribute() : attribute(newState, oldState), element))
|
|
@@ -429,7 +429,7 @@ const updateReplacer = (ctx, element, elCtx) => (_, oldValue) => {
|
|
|
429
429
|
let rendered = renderNode(evaluateElement(element, ctx.currentValue, oldValue))
|
|
430
430
|
if (rendered !== undefined) {
|
|
431
431
|
if (elCtx.current.key !== undefined) {
|
|
432
|
-
rendered.
|
|
432
|
+
rendered.key = elCtx.current.key
|
|
433
433
|
}
|
|
434
434
|
if (ctx.parentCtx) {
|
|
435
435
|
for (const bindContext of ctx.parentCtx.bindContexts) {
|