Skip to content

Commit

Permalink
Merge pull request #62 from marko-js/59-input-dependency
Browse files Browse the repository at this point in the history
fix: input dependencies with compiler update
  • Loading branch information
LuLaValva authored Aug 12, 2024
2 parents fd8b603 + 08f3dcc commit 24a7fb6
Show file tree
Hide file tree
Showing 9 changed files with 2,193 additions and 2,407 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-cars-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/tags-api-preview": patch
---

Fix input dependency tracking
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Use node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
Expand Down
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
18 changes: 18 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,24 @@ describe(
]),
);

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

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

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

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

-- ${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 24a7fb6

Please sign in to comment.