Skip to content

Commit

Permalink
fix: input dependencies with compiler update
Browse files Browse the repository at this point in the history
  • Loading branch information
LuLaValva committed Aug 12, 2024
1 parent e982500 commit 495fd99
Show file tree
Hide file tree
Showing 7 changed files with 2,191 additions and 2,406 deletions.
4,554 changes: 2,154 additions & 2,400 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
21 changes: 21 additions & 0 deletions src/__tests__/fixtures/effect/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ describe(
]),
);

describe(
"<effect> read-input",
fixture("./templates/read-input.marko", [
{ onCount, onCleanup, count: 1 },
async ({ expect, rerender }) => {
expect(onCount).calledOnceWith(1);
expect(onCleanup).has.not.been.called;
resetHistory();

await rerender();
expect(onCount).has.not.been.called;
expect(onCleanup).has.not.been.called;

await rerender({ onCount, onCleanup, count: 2 });
expect(onCount).calledOnceWith(2);
expect(onCleanup).has.been.calledOnce;
resetHistory();
},
]),
);

describe(
"<effect> multiple",
fixture("./templates/multiple.marko", [
Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/fixtures/effect/templates/read-input.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<effect() {
input.onCount(input.count);
return input.onCleanup;
}/>

-- ${input.count}
13 changes: 7 additions & 6 deletions src/transform/cached-values/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ const depsVisitor = {

if (
binding
? binding.path.isMarkoTag() &&
!(
binding.path === state.parentTag ||
isNativeTag(binding.path) ||
isDynamicTag(binding.path)
)
? binding.path.isMarkoTag()
? !(
binding.path === state.parentTag ||
isNativeTag(binding.path) ||
isDynamicTag(binding.path)
)
: name === "input" && binding.path.isProgram()
: name === "input" || name === "$global"
) {
let deps = state.deps || (state.deps = {});
Expand Down

0 comments on commit 495fd99

Please sign in to comment.