Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
perf($parse): don't bind filters to a context
Browse files Browse the repository at this point in the history
This change gives us ~10% boost in Chrome, less or nothing in other browsers.

BREAKING CHANGE:  `this` in filters is now undefined and no longer the scope

It's a bad practice for filters to have hidden dependencies, so pulling stuff from scope directly
is not a good idea. Scope being the filter context was never documented as public api, so we don't
expect that any significant code depends on this behavior.

If an existing filter has a dependency on the scope instance, the scope reference can
be passed into the filter as a filter argument (this is highly discouraged for new code):

Before: `{{ user.name | customFilter }}`
After: `{{ user.name | customFilter:this }}`
  • Loading branch information
IgorMinar committed Aug 20, 2014
1 parent d18b281 commit 8863b9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,10 @@ Parser.prototype = {
args[i + 1] = argsFn[i](self, locals);
}

return fn.apply(self, args);
return fn.apply(undefined, args);
}

return fn.call(self, input);
return fn(input);
});
},

Expand Down

0 comments on commit 8863b9d

Please sign in to comment.