Skip to content

Commit

Permalink
Fix issue where <tag bind=value> may not work outside of <self>
Browse files Browse the repository at this point in the history
  • Loading branch information
somebee committed Apr 26, 2024
1 parent baeec74 commit 4632723
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/imba/changelog.md
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

* Fix issue where `<tag bind=value>` may not work outside of `<self>`

## 2.0.0-alpha.236

* Fix issue with self in functional components.
Expand Down
12 changes: 8 additions & 4 deletions packages/imba/src/compiler/nodes.imba1
Expand Up @@ -11104,6 +11104,9 @@ export class Tag < TagLike
let alit = target and target.isConstant # isa Literal or target isa ScopeContext
let blit = key and key.isConstant # isa Literal or key isa SymbolIdentifier

if target isa Self and !root.isSelf
alit = false

if alit and blit
bval = "[{target.c(o)},{key.c(o)}]"

Expand All @@ -11112,10 +11115,11 @@ export class Tag < TagLike

add "{vvar}={iref} || ({iref}={ref}.bind$('{item.key}',{bval}))"

for part,i in val
unless part and part.isConstant # isa Literal
add "{vvar}[{i}]={part.c(o)}"
# add "({vvar}={rawVal.c(o)},{vvar}=={ref}.value || ({iref}={ref}.bind$('{item.key}',{mods},{bval}))"
if target and !alit
add "{vvar}[0]={target.c(o)}"
if key and !blit
add "{vvar}[0]={key.c(o)}"

elif val isa Variable
let getter = "function()\{ return {val.c(o)} \}"
let setter = "function(v$)\{ {val.c(o)} = v$ \}"
Expand Down

0 comments on commit 4632723

Please sign in to comment.