Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(compiler): don't create watchers for attr mappings if no attr is …
Browse files Browse the repository at this point in the history
…specified

Closes #265
  • Loading branch information
pavelgj committed Nov 15, 2013
1 parent 75a0f3d commit eb6ba0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/core_dom/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class Compiler {
break;
case '<=>':
mappingFn = (NodeAttrs attrs, Scope scope, Object dst) {
if (attrs[attrName] == null) return;
Expression attrExprFn = _parser(attrs[attrName]);
var shadowValue = null;
scope.$watch(
Expand All @@ -172,6 +173,7 @@ class Compiler {
break;
case '=>':
mappingFn = (NodeAttrs attrs, Scope scope, Object dst) {
if (attrs[attrName] == null) return;
Expression attrExprFn = _parser(attrs[attrName]);
var shadowValue = null;
scope.$watch(
Expand All @@ -182,6 +184,7 @@ class Compiler {
break;
case '=>!':
mappingFn = (NodeAttrs attrs, Scope scope, Object dst) {
if (attrs[attrName] == null) return;
Expression attrExprFn = _parser(attrs[attrName]);
var stopWatching;
stopWatching = scope.$watch(
Expand Down
8 changes: 8 additions & 0 deletions test/core_dom/compiler_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ main() => describe('dte.compiler', () {
expect($rootScope.done).toEqual(true);
})));

it('should should not create any watchers if no attributes are specified', async(inject((Profiler perf) {
var element = $(r'<div><io></io></div>');
$compile(element)(injector, element);
microLeap();
injector.get(Scope).$digest();
expect(perf.counters['ng.scope.watchers']).toEqual(0);
})));

it('should create a component with I/O and "=" binding value should be available', async(inject(() {
$rootScope.name = 'misko';
var element = $(r'<div><io attr="A" expr="name" ondone="done=true"></io></div>');
Expand Down

0 comments on commit eb6ba0d

Please sign in to comment.