-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfb62c3
commit b6bc25d
Showing
23 changed files
with
371 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@marko/tags-api-preview": minor | ||
--- | ||
|
||
Improve caching to be more like Marko 6. Fixes an issue with conditionally caching functions. |
6 changes: 6 additions & 0 deletions
6
src/__tests__/fixtures/let/__snapshots__/let-with-cacheable-value/node.render.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div> | ||
1 | ||
</div> | ||
<button> | ||
Increment | ||
</button> |
6 changes: 6 additions & 0 deletions
6
src/__tests__/fixtures/let/__snapshots__/let-with-cacheable-value/web.render.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div> | ||
1 | ||
</div> | ||
<button> | ||
Increment | ||
</button> |
6 changes: 6 additions & 0 deletions
6
src/__tests__/fixtures/let/__snapshots__/let-with-cacheable-value/web.step-0.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div> | ||
2 | ||
</div> | ||
<button> | ||
Increment | ||
</button> |
6 changes: 6 additions & 0 deletions
6
src/__tests__/fixtures/let/__snapshots__/let-with-cacheable-value/web.step-1.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div> | ||
3 | ||
</div> | ||
<button> | ||
Increment | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/__tests__/fixtures/let/templates/with-cacheable-value.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<attrs/{ value }/> | ||
<let/getCount() { return value; }/> | ||
|
||
<div>${getCount()}</div> | ||
<button onClick=(() => { | ||
const newCount = getCount() + 1; | ||
getCount = () => newCount; | ||
})>Increment</button> |
12 changes: 12 additions & 0 deletions
12
...cached-conditional-value/__snapshots__/cached-conditional-value/node.render.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
Count: 0 | ||
</div> | ||
<div> | ||
Message: | ||
</div> | ||
<button> | ||
Increment | ||
</button> | ||
<button> | ||
Toggle | ||
</button> |
12 changes: 12 additions & 0 deletions
12
.../cached-conditional-value/__snapshots__/cached-conditional-value/web.render.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
Count: 0 | ||
</div> | ||
<div> | ||
Message: | ||
</div> | ||
<button> | ||
Increment | ||
</button> | ||
<button> | ||
Toggle | ||
</button> |
12 changes: 12 additions & 0 deletions
12
.../cached-conditional-value/__snapshots__/cached-conditional-value/web.step-0.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
Count: 1 | ||
</div> | ||
<div> | ||
Message: | ||
</div> | ||
<button> | ||
Increment | ||
</button> | ||
<button> | ||
Toggle | ||
</button> |
12 changes: 12 additions & 0 deletions
12
.../cached-conditional-value/__snapshots__/cached-conditional-value/web.step-1.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
Count: 1 | ||
</div> | ||
<div> | ||
Message: hello 1 | ||
</div> | ||
<button> | ||
Increment | ||
</button> | ||
<button> | ||
Toggle | ||
</button> |
12 changes: 12 additions & 0 deletions
12
.../cached-conditional-value/__snapshots__/cached-conditional-value/web.step-2.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
Count: 1 | ||
</div> | ||
<div> | ||
Message: | ||
</div> | ||
<button> | ||
Increment | ||
</button> | ||
<button> | ||
Toggle | ||
</button> |
12 changes: 12 additions & 0 deletions
12
.../cached-conditional-value/__snapshots__/cached-conditional-value/web.step-3.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
Count: 2 | ||
</div> | ||
<div> | ||
Message: | ||
</div> | ||
<button> | ||
Increment | ||
</button> | ||
<button> | ||
Toggle | ||
</button> |
12 changes: 12 additions & 0 deletions
12
.../cached-conditional-value/__snapshots__/cached-conditional-value/web.step-4.expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
Count: 2 | ||
</div> | ||
<div> | ||
Message: hello 2 | ||
</div> | ||
<button> | ||
Increment | ||
</button> | ||
<button> | ||
Toggle | ||
</button> |
20 changes: 20 additions & 0 deletions
20
src/__tests__/fixtures/misc/cached-conditional-value/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import fixture, { FixtureHelpers } from "../../../fixture"; | ||
const increment = click("Increment"); | ||
const toggle = click("Toggle"); | ||
|
||
describe( | ||
"cached conditional value", | ||
fixture("./templates/basic.marko", [ | ||
{}, | ||
increment, | ||
toggle, | ||
toggle, | ||
increment, | ||
toggle, | ||
]) | ||
); | ||
|
||
function click(text: string) { | ||
return async ({ fireEvent, screen }: FixtureHelpers) => | ||
await fireEvent.click(screen.getByText(text)); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/__tests__/fixtures/misc/cached-conditional-value/templates/basic.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<let/enabled = false/> | ||
<let/count = 0/> | ||
<const/dynamicMessage = enabled ? () => `hello ${count}` : undefined/> | ||
<div>Count: ${count}</div> | ||
<div>Message: ${dynamicMessage?.()}</div> | ||
<button onClick=(() => count++)>Increment</button> | ||
<button onClick=(() => enabled = !enabled)>Toggle</button> |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.