@srfnstack/fntags 1.1.0 → 1.1.1

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 +1 -1
  2. package/src/fntags.mjs +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srfnstack/fntags",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "author": "Robert Kempton <r@snow87.com>",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/srfnstack/fntags",
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))