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

refactor(*): remove ignored expensiveChecks argument to $parse() #15680

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/ng/directive/ngEventDirs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ forEach(
return {
restrict: 'A',
compile: function($element, attr) {
// We expose the powerful $event object on the scope that provides access to the Window,
// etc. that isn't protected by the fast paths in $parse. We explicitly request better
// checks at the cost of speed since event handler expressions are not executed as
// frequently as regular change detection.
var fn = $parse(attr[directiveName], /* interceptorFn */ null, /* expensiveChecks */ true);
// NOTE:
// We expose the powerful `$event` object on the scope that provides access to the Window,
// etc. This is OK, because expressions are not sandboxed any more (and the expression
// sandbox was never meant to be a security feature anyway).
var fn = $parse(attr[directiveName]);
return function ngEventHandler(scope, element) {
element.on(eventName, function(event) {
var callback = function() {
fn(scope, {$event:event});
fn(scope, {$event: event});
};
if (forceAsyncEvents[eventName] && $rootScope.$$phase) {
scope.$evalAsync(callback);
Expand Down
2 changes: 1 addition & 1 deletion src/ngAria/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
return {
restrict: 'A',
compile: function(elem, attr) {
var fn = $parse(attr.ngClick, /* interceptorFn */ null, /* expensiveChecks */ true);
var fn = $parse(attr.ngClick);
return function(scope, elem, attr) {

if (!isNodeOneOf(elem, nodeBlackList)) {
Expand Down
19 changes: 0 additions & 19 deletions test/ng/parseSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2635,25 +2635,6 @@ describe('parser', function() {
expect(log).toEqual('');
}));

it('should work with expensive checks', inject(function($parse, $rootScope, log) {
var fn = $parse('::foo', null, true);
$rootScope.$watch(fn, function(value, old) { if (value !== old) log(value); });

$rootScope.$digest();
expect($rootScope.$$watchers.length).toBe(1);

$rootScope.foo = 'bar';
$rootScope.$digest();
expect($rootScope.$$watchers.length).toBe(0);
expect(log).toEqual('bar');
log.reset();

$rootScope.foo = 'man';
$rootScope.$digest();
expect($rootScope.$$watchers.length).toBe(0);
expect(log).toEqual('');
}));

it('should have a stable value if at the end of a $digest it has a defined value', inject(function($parse, $rootScope, log) {
var fn = $parse('::foo');
$rootScope.$watch(fn, function(value, old) { if (value !== old) log(value); });
Expand Down