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

Local scope.$digest can trigger $rootScope.$apply via a < binding #15484

Open
@samal-rasmussen

Description

@samal-rasmussen

Do you want to request a feature or report a bug?

bug

What is the current behavior?

A call to a local scope.$digest can trigger a < binding watcher. A < binding watcher will call $rootScope.$apply.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).

The watcher for the < binding calls recordChanges(), which calls flushOnChangesQueue(), which calls rootScope.$apply. See:
https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L1516

What is the expected behavior?

I thought I could expect a local scope.$digest to only call its own watchers and those of its children. This would be a great performance gain in specific use cases.

What is the motivation / use case for changing the behavior?

Being able to have local scope digest cycles may be necessary for some large Angular applications, as rootscope digest might be too expensive, either because there are too many watchers in a large app, or because there are many push updates from the backend.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.

This affects the latest commit to the file in question: https://github.com/angular/angular.js/blob/736b6c7fed79c8305786bbb86d39dd7af891a162/src/ng/compile.js

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Maybe we should be able to configure per < binding whether or not we want the watcher to trigger a $rootScope.$apply or a scope.$digest.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions