Skip to content

Commit

Permalink
fix: get tag not updating when set tag context is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Khauri committed Dec 23, 2021
1 parent 5d2c9f0 commit d80b781
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
1
</div>
<button>
increment
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
1
</div>
<button>
increment
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
2
</div>
<button>
increment
</button>
9 changes: 9 additions & 0 deletions src/__tests__/fixtures/get-and-set/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ describe(
])
);

describe(
"<get> & <set> update provided value",
fixture("./templates/update-provided-value/index.marko", [
async ({ screen, fireEvent }) => {
await fireEvent.click(screen.getByText("increment"));
},
])
);

describe(
"<get> & <set> reference by tag name",
fixture("./templates/reference-by-tag-name/index.marko")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<get/val="../index.marko"/>
<div>${val}</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<let/value=1 />

<set=value>
<child/>
<button onClick=(() => value = 2)>increment</button>
</set>
2 changes: 1 addition & 1 deletion src/components/get/index.marko
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class {
if (this.provider) {
if (typeof window === "object") {
this.sub = this.subscribeTo(this.provider).on("___change", this.sync);
this.sub = this.subscribeTo(this.provider).on("___changed", this.sync);
}
this.data = this.provider.input;
Expand Down
3 changes: 1 addition & 2 deletions src/components/set/index.marko
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ $ {
<${input.renderBody}/>

$ {
if (typeof window === "object" && !component.___rendered) {
component.___rendered = true;
if (typeof window === "object" && typeof component.emit === "function") {
component.emit("___changed");
}
Expand Down

0 comments on commit d80b781

Please sign in to comment.