Skip to content

Commit

Permalink
Looks like the mitigation for #1061 fixes #1043
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Apr 1, 2020
1 parent 115ff70 commit 8ffbb99
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ComputedData.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class ComputedData {
let output;
let savedLog = console.log;
console.log = () => {};
// Mitigation for #1061, errors on the first pass shouldn’t fail the whole thing.
try {
// Mitigation for #1061, errors on the first pass shouldn’t fail the whole thing.
output = await computed(proxyData);
} catch (e) {
debug("Computed Data first pass data resolution error: %o", e);
Expand Down
15 changes: 15 additions & 0 deletions test/TemplateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2142,3 +2142,18 @@ test("eleventyComputed true primitive", async t => {
t.is(data.key3, false);
t.is(data.key4, 324);
});

test("eleventyComputed relies on global data", async t => {
let dataObj = new TemplateData("./test/stubs/");
let tmpl = new Template(
"./test/stubs/eleventyComputed/use-global-data.njk",
"./test/stubs/",
"./dist",
dataObj
);

let fetchedData = await tmpl.getData();
let templates = await tmpl.getTemplates(fetchedData);
let data = templates[0].data;
t.is(data.image, "datavalue1");
});
10 changes: 10 additions & 0 deletions test/stubs/eleventyComputed/use-global-data.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---js
{
eleventyComputed: {
image: data => {
return data.globalData.datakey1;
}
}
}
---
Issue #1043

0 comments on commit 8ffbb99

Please sign in to comment.