-
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.
* fix: don't cache call expressions unless event handlers * fix: cache function calls * chore: add changeset
- Loading branch information
Showing
21 changed files
with
150 additions
and
40 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": patch | ||
--- | ||
|
||
improve member expression caching |
6 changes: 6 additions & 0 deletions
6
...const/__snapshots__/const-state-derived-from-prototype-function/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 @@ | ||
<p> | ||
9 string length = 1 | ||
</p> | ||
<button> | ||
increment | ||
</button> |
6 changes: 6 additions & 0 deletions
6
.../const/__snapshots__/const-state-derived-from-prototype-function/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 @@ | ||
<p> | ||
9 string length = 1 | ||
</p> | ||
<button> | ||
increment | ||
</button> |
6 changes: 6 additions & 0 deletions
6
.../const/__snapshots__/const-state-derived-from-prototype-function/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 @@ | ||
<p> | ||
10 string length = 2 | ||
</p> | ||
<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
4 changes: 4 additions & 0 deletions
4
src/__tests__/fixtures/const/templates/state-derived-prototype-function.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,4 @@ | ||
<let/value=9/> | ||
<const/length=value.toString().length/> | ||
<p>${value} string length = ${length}</p> | ||
<button onClick=(() => value++)>increment</button> |
20 changes: 0 additions & 20 deletions
20
src/__tests__/fixtures/misc/cached-conditional-value/index.test.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...ests__/fixtures/misc/caching/__snapshots__/cached/function-call/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,3 @@ | ||
<button> | ||
increment | ||
</button> |
3 changes: 3 additions & 0 deletions
3
...tests__/fixtures/misc/caching/__snapshots__/cached/function-call/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,3 @@ | ||
<button> | ||
increment | ||
</button> |
3 changes: 3 additions & 0 deletions
3
...tests__/fixtures/misc/caching/__snapshots__/cached/function-call/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,3 @@ | ||
<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { resetHistory, spy } from "sinon"; | ||
import fixture, { FixtureHelpers } from "../../../fixture"; | ||
const increment = click("Increment"); | ||
const toggle = click("Toggle"); | ||
|
||
const onRender = spy(); | ||
|
||
describe("cached", () => { | ||
beforeEach(() => resetHistory()); | ||
|
||
describe( | ||
"conditional value", | ||
fixture("./templates/conditional-value.marko", [ | ||
{}, | ||
increment, | ||
toggle, | ||
toggle, | ||
increment, | ||
toggle, | ||
]) | ||
); | ||
|
||
describe( | ||
"function call", | ||
fixture("./templates/function-call.marko", [ | ||
{ fn: onRender }, | ||
async ({ expect, screen, fireEvent, rerender }) => { | ||
expect(onRender).calledOnce; | ||
resetHistory(); | ||
expect(onRender).not.called; | ||
|
||
await fireEvent.click(screen.getByText("increment")); | ||
expect(onRender).not.called; | ||
resetHistory(); | ||
|
||
await rerender(); | ||
expect(onRender).not.called; | ||
resetHistory(); | ||
|
||
await rerender({ fn: () => onRender() }); | ||
expect(onRender).calledOnce; | ||
resetHistory(); | ||
}, | ||
]) | ||
); | ||
}); | ||
|
||
function click(text: string) { | ||
return async ({ fireEvent, screen }: FixtureHelpers) => | ||
await fireEvent.click(screen.getByText(text)); | ||
} |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
src/__tests__/fixtures/misc/caching/templates/function-call.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,3 @@ | ||
<let/count=0/> | ||
<button onClick=(() => count++)>increment</button> | ||
<const/_=input.fn()/> |
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