Skip to content

Commit

Permalink
Fixes #3365
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jul 15, 2024
1 parent 8dbc554 commit 926818e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/UserConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ class UserConfig {
* Universal getters
*/
getFilter(name) {
return this.universal.filters[name];
// JavaScript functions are included here for backwards compatibility https://github.com/11ty/eleventy/issues/3365
return this.universal.filters[name] || this.javascript.functions[name];
}

getFilters(options = {}) {
Expand Down
8 changes: 8 additions & 0 deletions test/UserConfigTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,11 @@ test("Memoize async filters (memoized)", async (t) => {
await increment(3);
t.is(count, 6);
});

// JavaScript functions are included here for backwards compatibility https://github.com/11ty/eleventy/issues/3365
test("addJavaScriptFunction feeds into `getFilter` #3365", (t) => {
let userCfg = new UserConfig();
userCfg.addJavaScriptFunction("increment", num => num++);

t.is(typeof userCfg.getFilter("increment"), "function");
});

0 comments on commit 926818e

Please sign in to comment.