diff --git a/modules/angular2/src/render/dom/compiler/compile_control.js b/modules/angular2/src/render/dom/compiler/compile_control.js
index 89faa46e03..facc8cb84a 100644
--- a/modules/angular2/src/render/dom/compiler/compile_control.js
+++ b/modules/angular2/src/render/dom/compiler/compile_control.js
@@ -13,6 +13,8 @@ export class CompileControl {
_parent:CompileElement;
_results;
_additionalChildren;
+ _ignoreCurrentElement: boolean;
+
constructor(steps) {
this._steps = steps;
this._currentStepIndex = 0;
@@ -27,14 +29,21 @@ export class CompileControl {
var previousStepIndex = this._currentStepIndex;
var previousParent = this._parent;
- for (var i=startStepIndex; i' : used to provide context in case of error
constructor(element, compilationUnit = '') {
@@ -34,8 +33,6 @@ export class CompileElement {
this.inheritedElementBinder = null;
this.distanceToInheritedBinder = 0;
this.compileChildren = true;
- // set to true to ignore all the bindings on the element
- this.ignoreBindings = false;
// description is calculated here as compilation steps may change the element
var tplDesc = assertionsEnabled()? getElementDescription(element) : null;
if (compilationUnit !== '') {
diff --git a/modules/angular2/src/render/dom/compiler/property_binding_parser.js b/modules/angular2/src/render/dom/compiler/property_binding_parser.js
index 1383c57de5..978853230e 100644
--- a/modules/angular2/src/render/dom/compiler/property_binding_parser.js
+++ b/modules/angular2/src/render/dom/compiler/property_binding_parser.js
@@ -30,10 +30,6 @@ export class PropertyBindingParser extends CompileStep {
}
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
- if (current.ignoreBindings) {
- return;
- }
-
var attrs = current.attrs();
var newAttrs = MapWrapper.create();
diff --git a/modules/angular2/src/render/dom/compiler/text_interpolation_parser.js b/modules/angular2/src/render/dom/compiler/text_interpolation_parser.js
index 1a056c138d..2758ae55fc 100644
--- a/modules/angular2/src/render/dom/compiler/text_interpolation_parser.js
+++ b/modules/angular2/src/render/dom/compiler/text_interpolation_parser.js
@@ -19,7 +19,7 @@ export class TextInterpolationParser extends CompileStep {
}
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
- if (!current.compileChildren || current.ignoreBindings) {
+ if (!current.compileChildren) {
return;
}
var element = current.element;
diff --git a/modules/angular2/src/render/dom/shadow_dom/shadow_dom_compile_step.js b/modules/angular2/src/render/dom/shadow_dom/shadow_dom_compile_step.js
index 8a42b9337e..3054ef5564 100644
--- a/modules/angular2/src/render/dom/shadow_dom/shadow_dom_compile_step.js
+++ b/modules/angular2/src/render/dom/shadow_dom/shadow_dom_compile_step.js
@@ -23,12 +23,9 @@ export class ShadowDomCompileStep extends CompileStep {
}
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
- if (current.ignoreBindings) {
- return;
- }
var tagName = DOM.tagName(current.element).toUpperCase();
if (tagName == 'STYLE') {
- this._processStyleElement(current);
+ this._processStyleElement(current, control);
} else if (tagName == 'CONTENT') {
this._processContentElement(current);
} else {
@@ -39,17 +36,20 @@ export class ShadowDomCompileStep extends CompileStep {
}
}
- _processStyleElement(current) {
- current.ignoreBindings = true;
+ _processStyleElement(current:CompileElement, control:CompileControl) {
var stylePromise = this._shadowDomStrategy.processStyleElement(
this._template.componentId, this._template.absUrl, current.element
);
if (isPresent(stylePromise) && PromiseWrapper.isPromise(stylePromise)) {
ListWrapper.push(this._subTaskPromises, stylePromise);
}
+
+ // Style elements should not be further processed by the compiler, as they can not contain
+ // bindings. Skipping further compiler steps allow speeding up the compilation process.
+ control.ignoreCurrentElement();
}
- _processContentElement(current) {
+ _processContentElement(current:CompileElement) {
if (this._shadowDomStrategy.hasNativeContentElement()) {
return;
}
diff --git a/modules/angular2/test/render/dom/compiler/pipeline_spec.js b/modules/angular2/test/render/dom/compiler/pipeline_spec.js
index ff88cc840a..3fec0d348e 100644
--- a/modules/angular2/test/render/dom/compiler/pipeline_spec.js
+++ b/modules/angular2/test/render/dom/compiler/pipeline_spec.js
@@ -80,6 +80,19 @@ export function main() {
expect(results[3].inheritedElementBinder.parent).toBe(results[0].inheritedElementBinder);
});
+ it('should not execute further steps when ignoreCurrentElement has been called', () => {
+ var element = el('
');
+ var logs = [];
+ var pipeline = new CompilePipeline([
+ new IgnoreCurrentElementStep(),
+ createLoggerStep(logs),
+ ]);
+ var results = pipeline.process(element);
+
+ expect(results.length).toBe(2);
+ expect(logs).toEqual(['1', '1<3'])
+ });
+
describe('control.addParent', () => {
it('should report the new parent to the following processor and the result', () => {
var element = el('
');
@@ -188,6 +201,15 @@ export class IgnoreChildrenStep extends CompileStep {
}
}
+class IgnoreCurrentElementStep extends CompileStep {
+ process(parent:CompileElement, current:CompileElement, control:CompileControl) {
+ var attributeMap = DOM.attributeMap(current.element);
+ if (MapWrapper.contains(attributeMap, 'ignore-current')) {
+ control.ignoreCurrentElement();
+ }
+ }
+}
+
function logEntry(log, parent, current) {
var parentId = '';
if (isPresent(parent)) {
@@ -223,4 +245,4 @@ function resultIdLog(result) {
logEntry(idLog, null, current);
});
return idLog;
-}
\ No newline at end of file
+}
diff --git a/modules/angular2/test/render/dom/compiler/property_binding_parser_spec.js b/modules/angular2/test/render/dom/compiler/property_binding_parser_spec.js
index e7060d2ba0..a880493f93 100644
--- a/modules/angular2/test/render/dom/compiler/property_binding_parser_spec.js
+++ b/modules/angular2/test/render/dom/compiler/property_binding_parser_spec.js
@@ -11,10 +11,9 @@ var EMPTY_MAP = MapWrapper.create();
export function main() {
describe('PropertyBindingParser', () => {
- function createPipeline(ignoreBindings = false, hasNestedProtoView = false) {
+ function createPipeline(hasNestedProtoView = false) {
return new CompilePipeline([
new MockStep((parent, current, control) => {
- current.ignoreBindings = ignoreBindings;
if (hasNestedProtoView) {
current.bindElement().bindNestedProtoView(el(''));
}
@@ -22,18 +21,13 @@ export function main() {
new PropertyBindingParser(new Parser(new Lexer()))]);
}
- function process(element, ignoreBindings = false, hasNestedProtoView = false) {
+ function process(element, hasNestedProtoView = false) {
return ListWrapper.map(
- createPipeline(ignoreBindings, hasNestedProtoView).process(element),
+ createPipeline(hasNestedProtoView).process(element),
(compileElement) => compileElement.inheritedElementBinder
);
}
- it('should not parse bindings when ignoreBindings is true', () => {
- var results = process(el(''), true);
- expect(results[0]).toEqual(null);
- });
-
it('should detect [] syntax', () => {
var results = process(el(''));
expect(MapWrapper.get(results[0].propertyBindings, 'a').source).toEqual('b');
@@ -64,13 +58,13 @@ export function main() {
});
it('should store variable binding for a template element on the nestedProtoView', () => {
- var results = process(el('
'), false, true);
+ var results = process(el(''), true);
expect(results[0].variableBindings).toEqual(EMPTY_MAP);
expect(MapWrapper.get(results[0].nestedProtoView.variableBindings, 'washington')).toEqual('george');
});
it('should store variable binding for a non-template element using shorthand syntax on the nestedProtoView', () => {
- var results = process(el(''), false, true);
+ var results = process(el(''), true);
expect(results[0].variableBindings).toEqual(EMPTY_MAP);
expect(MapWrapper.get(results[0].nestedProtoView.variableBindings, 'washington')).toEqual('george');
});
diff --git a/modules/angular2/test/render/dom/compiler/text_interpolation_parser_spec.js b/modules/angular2/test/render/dom/compiler/text_interpolation_parser_spec.js
index 39cf15a5e9..0e3ff7722d 100644
--- a/modules/angular2/test/render/dom/compiler/text_interpolation_parser_spec.js
+++ b/modules/angular2/test/render/dom/compiler/text_interpolation_parser_spec.js
@@ -3,24 +3,20 @@ import {TextInterpolationParser} from 'angular2/src/render/dom/compiler/text_int
import {CompilePipeline} from 'angular2/src/render/dom/compiler/compile_pipeline';
import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {Lexer, Parser} from 'angular2/change_detection';
-import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element';
-import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step'
-import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control';
import {IgnoreChildrenStep} from './pipeline_spec';
export function main() {
describe('TextInterpolationParser', () => {
- function createPipeline(ignoreBindings = false) {
+ function createPipeline() {
return new CompilePipeline([
- new MockStep((parent, current, control) => { current.ignoreBindings = ignoreBindings; }),
new IgnoreChildrenStep(),
new TextInterpolationParser(new Parser(new Lexer()))
]);
}
- function process(element, ignoreBindings = false) {
+ function process(element) {
return ListWrapper.map(
- createPipeline(ignoreBindings).process(element),
+ createPipeline().process(element),
(compileElement) => compileElement.inheritedElementBinder
);
}
@@ -30,11 +26,6 @@ export function main() {
expect(elementBinder.textBindingIndices[bindingIndex]).toEqual(nodeIndex);
}
- it('should not look for text interpolation when ignoreBindings is true', () => {
- var results = process(el('{{expr1}}{{expr2}}
'), true);
- expect(results[0]).toEqual(null);
- });
-
it('should find text interpolation in normal elements', () => {
var result = process(el('{{expr1}}{{expr2}}
'))[0];
assertTextBinding(result, 0, 0, "{{expr1}}");
@@ -69,14 +60,3 @@ export function main() {
});
});
}
-
-class MockStep extends CompileStep {
- processClosure:Function;
- constructor(process) {
- super();
- this.processClosure = process;
- }
- process(parent:CompileElement, current:CompileElement, control:CompileControl) {
- this.processClosure(parent, current, control);
- }
-}