refactor(ChangeDetector): rename WatchGroup into RecordRange

This commit is contained in:
vsavkin
2014-11-19 15:52:01 -08:00
parent 862c6412c4
commit 2980eb5b0b
14 changed files with 411 additions and 384 deletions

View File

@ -24,12 +24,12 @@ export function main() {
compiler = new Compiler(null, new Reflector(), new Parser(new Lexer(), closureMap), closureMap);
});
describe('react to watch group changes', function() {
describe('react to record changes', function() {
var view, ctx, cd;
function createView(pv) {
ctx = new MyComp();
view = pv.instantiate(ctx, new Injector([]), null);
cd = new ChangeDetector(view.watchGroup);
cd = new ChangeDetector(view.recordRange);
}
it('should consume text node changes', (done) => {

View File

@ -16,7 +16,7 @@ import {ProtoView, ElementPropertyMemento, DirectivePropertyMemento} from 'core/
import {ProtoElementInjector} from 'core/compiler/element_injector';
import {Reflector} from 'core/compiler/reflector';
import {ProtoWatchGroup} from 'change_detection/watch_group';
import {ProtoRecordRange} from 'change_detection/record_range';
import {Parser} from 'change_detection/parser/parser';
import {Lexer} from 'change_detection/parser/lexer';
import {ClosureMap} from 'change_detection/parser/closure_map';
@ -36,7 +36,7 @@ export function main() {
new MockStep((parent, current, control) => {
if (isPresent(current.element.getAttribute('viewroot'))) {
current.isViewRoot = true;
current.inheritedProtoView = new ProtoView(current.element, new ProtoWatchGroup());
current.inheritedProtoView = new ProtoView(current.element, new ProtoRecordRange());
} else if (isPresent(parent)) {
current.inheritedProtoView = parent.inheritedProtoView;
}
@ -81,7 +81,7 @@ export function main() {
function instantiateView(protoView) {
evalContext = new Context();
view = protoView.instantiate(evalContext, new Injector([]), null);
changeDetector = new ChangeDetector(view.watchGroup);
changeDetector = new ChangeDetector(view.recordRange);
}
it('should not create an ElementBinder for elements that have no bindings', () => {
@ -206,7 +206,7 @@ export function main() {
var results = pipeline.process(createElement('<div viewroot prop-binding directives></div>'));
var pv = results[0].inheritedProtoView;
results[0].inheritedElementBinder.nestedProtoView = new ProtoView(
createElement('<div></div>'), new ProtoWatchGroup());
createElement('<div></div>'), new ProtoRecordRange());
instantiateView(pv);
evalContext.prop1 = 'a';

View File

@ -4,7 +4,7 @@ import {ProtoElementInjector, ElementInjector} from 'core/compiler/element_injec
import {Reflector} from 'core/compiler/reflector';
import {Component} from 'core/annotations/component';
import {Decorator} from 'core/annotations/decorator';
import {ProtoWatchGroup} from 'change_detection/watch_group';
import {ProtoRecordRange} from 'change_detection/record_range';
import {ChangeDetector} from 'change_detection/change_detector';
import {TemplateConfig} from 'core/annotations/template_config';
import {Parser} from 'change_detection/parser/parser';
@ -35,7 +35,7 @@ export function main() {
}
it('should collect the root node in the ProtoView element', () => {
var pv = new ProtoView(templateAwareCreateElement('<div id="1"></div>'), new ProtoWatchGroup());
var pv = new ProtoView(templateAwareCreateElement('<div id="1"></div>'), new ProtoRecordRange());
var view = pv.instantiate(null, null, null);
expect(view.nodes.length).toBe(1);
expect(view.nodes[0].getAttribute('id')).toEqual('1');
@ -44,7 +44,7 @@ export function main() {
describe('collect elements with property bindings', () => {
it('should collect property bindings on the root element if it has the ng-binding class', () => {
var pv = new ProtoView(templateAwareCreateElement('<div [prop]="a" class="ng-binding"></div>'), new ProtoWatchGroup());
var pv = new ProtoView(templateAwareCreateElement('<div [prop]="a" class="ng-binding"></div>'), new ProtoRecordRange());
pv.bindElement(null);
pv.bindElementProperty('prop', parser.parseBinding('a').ast);
@ -55,7 +55,7 @@ export function main() {
it('should collect property bindings on child elements with ng-binding class', () => {
var pv = new ProtoView(templateAwareCreateElement('<div><span></span><span class="ng-binding"></span></div>'),
new ProtoWatchGroup());
new ProtoRecordRange());
pv.bindElement(null);
pv.bindElementProperty('a', parser.parseBinding('b').ast);
@ -69,7 +69,7 @@ export function main() {
describe('collect text nodes with bindings', () => {
it('should collect text nodes under the root element', () => {
var pv = new ProtoView(templateAwareCreateElement('<div class="ng-binding">{{}}<span></span>{{}}</div>'), new ProtoWatchGroup());
var pv = new ProtoView(templateAwareCreateElement('<div class="ng-binding">{{}}<span></span>{{}}</div>'), new ProtoRecordRange());
pv.bindElement(null);
pv.bindTextNode(0, parser.parseBinding('a').ast);
pv.bindTextNode(2, parser.parseBinding('b').ast);
@ -82,7 +82,7 @@ export function main() {
it('should collect text nodes with bindings on child elements with ng-binding class', () => {
var pv = new ProtoView(templateAwareCreateElement('<div><span> </span><span class="ng-binding">{{}}</span></div>'),
new ProtoWatchGroup());
new ProtoRecordRange());
pv.bindElement(null);
pv.bindTextNode(0, parser.parseBinding('b').ast);
@ -97,14 +97,14 @@ export function main() {
describe('inplace instantiation', () => {
it('should be supported.', () => {
var template = createElement('<div></div>')
var view = new ProtoView(template, new ProtoWatchGroup())
var view = new ProtoView(template, new ProtoRecordRange())
.instantiate(null, null, null, true);
expect(view.nodes[0]).toBe(template);
});
it('should be off by default.', () => {
var template = createElement('<div></div>')
var view = new ProtoView(template, new ProtoWatchGroup())
var view = new ProtoView(template, new ProtoRecordRange())
.instantiate(null, null, null);
expect(view.nodes[0]).not.toBe(template);
});
@ -120,7 +120,7 @@ export function main() {
describe('create ElementInjectors', () => {
it('should use the directives of the ProtoElementInjector', () => {
var pv = new ProtoView(createElement('<div class="ng-binding"></div>'), new ProtoWatchGroup());
var pv = new ProtoView(createElement('<div class="ng-binding"></div>'), new ProtoRecordRange());
pv.bindElement(new ProtoElementInjector(null, 1, [SomeDirective]));
var view = pv.instantiate(null, null, null);
@ -130,7 +130,7 @@ export function main() {
it('should use the correct parent', () => {
var pv = new ProtoView(createElement('<div class="ng-binding"><span class="ng-binding"></span></div>'),
new ProtoWatchGroup());
new ProtoRecordRange());
var protoParent = new ProtoElementInjector(null, 0, [SomeDirective]);
pv.bindElement(protoParent);
pv.bindElement(new ProtoElementInjector(protoParent, 1, [AnotherDirective]));
@ -146,7 +146,7 @@ export function main() {
it('should collect a single root element injector', () => {
var pv = new ProtoView(createElement('<div class="ng-binding"><span class="ng-binding"></span></div>'),
new ProtoWatchGroup());
new ProtoRecordRange());
var protoParent = new ProtoElementInjector(null, 0, [SomeDirective]);
pv.bindElement(protoParent);
pv.bindElement(new ProtoElementInjector(protoParent, 1, [AnotherDirective]));
@ -158,7 +158,7 @@ export function main() {
it('should collect multiple root element injectors', () => {
var pv = new ProtoView(createElement('<div><span class="ng-binding"></span><span class="ng-binding"></span></div>'),
new ProtoWatchGroup());
new ProtoRecordRange());
pv.bindElement(new ProtoElementInjector(null, 1, [SomeDirective]));
pv.bindElement(new ProtoElementInjector(null, 2, [AnotherDirective]));
@ -174,7 +174,7 @@ export function main() {
var view, ctx;
function createComponentWithSubPV(subProtoView) {
var pv = new ProtoView(createElement('<cmp class="ng-binding"></cmp>'), new ProtoWatchGroup());
var pv = new ProtoView(createElement('<cmp class="ng-binding"></cmp>'), new ProtoRecordRange());
var binder = pv.bindElement(new ProtoElementInjector(null, 0, [SomeComponent], true));
binder.componentDirective = someComponentDirective;
binder.nestedProtoView = subProtoView;
@ -187,7 +187,7 @@ export function main() {
}
it('should create shadow dom', () => {
var subpv = new ProtoView(createElement('<span>hello shadow dom</span>'), new ProtoWatchGroup());
var subpv = new ProtoView(createElement('<span>hello shadow dom</span>'), new ProtoRecordRange());
var pv = createComponentWithSubPV(subpv);
var view = createNestedView(pv);
@ -196,7 +196,7 @@ export function main() {
});
it('should expose component services to the component', () => {
var subpv = new ProtoView(createElement('<span></span>'), new ProtoWatchGroup());
var subpv = new ProtoView(createElement('<span></span>'), new ProtoRecordRange());
var pv = createComponentWithSubPV(subpv);
var view = createNestedView(pv);
@ -208,7 +208,7 @@ export function main() {
it('should expose component services and component instance to directives in the shadow Dom',
() => {
var subpv = new ProtoView(
createElement('<div dec class="ng-binding">hello shadow dom</div>'), new ProtoWatchGroup());
createElement('<div dec class="ng-binding">hello shadow dom</div>'), new ProtoRecordRange());
var subBinder = subpv.bindElement(
new ProtoElementInjector(null, 0, [ServiceDependentDecorator]));
var pv = createComponentWithSubPV(subpv);
@ -226,18 +226,18 @@ export function main() {
});
});
describe('react to watch group changes', () => {
describe('react to record changes', () => {
var view, cd, ctx;
function createView(protoView) {
ctx = new MyEvaluationContext();
view = protoView.instantiate(ctx, null, null);
cd = new ChangeDetector(view.watchGroup);
cd = new ChangeDetector(view.recordRange);
}
it('should consume text node changes', () => {
var pv = new ProtoView(createElement('<div class="ng-binding">{{}}</div>'),
new ProtoWatchGroup());
new ProtoRecordRange());
pv.bindElement(null);
pv.bindTextNode(0, parser.parseBinding('foo').ast);
createView(pv);
@ -249,7 +249,7 @@ export function main() {
it('should consume element binding changes', () => {
var pv = new ProtoView(createElement('<div class="ng-binding"></div>'),
new ProtoWatchGroup());
new ProtoRecordRange());
pv.bindElement(null);
pv.bindElementProperty('id', parser.parseBinding('foo').ast);
createView(pv);
@ -261,7 +261,7 @@ export function main() {
it('should consume directive watch expression change.', () => {
var pv = new ProtoView(createElement('<div class="ng-binding"></div>'),
new ProtoWatchGroup());
new ProtoRecordRange());
pv.bindElement(new ProtoElementInjector(null, 0, [SomeDirective]));
pv.bindDirectiveProperty( 0, parser.parseBinding('foo').ast, 'prop', closureMap.setter('prop'));
createView(pv);
@ -277,7 +277,7 @@ export function main() {
var el, pv;
beforeEach(() => {
el = DOM.createElement('div');
pv = new ProtoView(createElement('<div>hi</div>'), new ProtoWatchGroup());
pv = new ProtoView(createElement('<div>hi</div>'), new ProtoRecordRange());
});
it('should create the root component when instantiated', () => {