diff --git a/modules/core/src/compiler/pipeline/compile_control.js b/modules/core/src/compiler/pipeline/compile_control.js index f7402a1a03..6cf6e8d8d3 100644 --- a/modules/core/src/compiler/pipeline/compile_control.js +++ b/modules/core/src/compiler/pipeline/compile_control.js @@ -1,5 +1,6 @@ +import {isBlank} from 'facade/lang'; import {List, ListWrapper} from 'facade/collection'; -import {DOM} from 'facade/dom'; +import {DOM, Element} from 'facade/dom'; import {CompileElement} from './compile_element'; import {CompileStep} from './compile_step'; @@ -13,12 +14,14 @@ export class CompileControl { _parent:CompileElement; _current:CompileElement; _results; + _additionalChildren; constructor(steps) { this._steps = steps; this._currentStepIndex = 0; this._parent = null; this._current = null; this._results = null; + this._additionalChildren = null; } // only public so that it can be used by compile_pipeline @@ -39,15 +42,21 @@ export class CompileControl { this._currentStepIndex = previousStepIndex; this._parent = previousParent; + + var localAdditionalChildren = this._additionalChildren; + this._additionalChildren = null; + return localAdditionalChildren; } addParent(newElement:CompileElement) { - var currEl = this._current.element; - var newEl = newElement.element; - DOM.parentElement(currEl).insertBefore(newEl, currEl); - DOM.appendChild(newEl, currEl); - this.internalProcess(this._results, this._currentStepIndex+1, this._parent, newElement); this._parent = newElement; } + + addChild(element:CompileElement) { + if (isBlank(this._additionalChildren)) { + this._additionalChildren = ListWrapper.create(); + } + ListWrapper.push(this._additionalChildren, element); + } } diff --git a/modules/core/src/compiler/pipeline/compile_pipeline.js b/modules/core/src/compiler/pipeline/compile_pipeline.js index bad8f809d8..087e0dd3f0 100644 --- a/modules/core/src/compiler/pipeline/compile_pipeline.js +++ b/modules/core/src/compiler/pipeline/compile_pipeline.js @@ -1,3 +1,4 @@ +import {isPresent} from 'facade/lang'; import {List, ListWrapper} from 'facade/collection'; import {Element, Node, DOM} from 'facade/dom'; import {CompileElement} from './compile_element'; @@ -17,18 +18,24 @@ export class CompilePipeline { process(rootElement:Element):List { var results = ListWrapper.create(); - this._process(results, null, rootElement); + this._process(results, null, new CompileElement(rootElement)); return results; } - _process(results, parent:CompileElement, element:Element) { - var current = new CompileElement(element); - this._control.internalProcess(results, 0, parent, current); - var childNodes = DOM.templateAwareRoot(element).childNodes; + _process(results, parent:CompileElement, current:CompileElement) { + var additionalChildren = this._control.internalProcess(results, 0, parent, current); + + var childNodes = DOM.templateAwareRoot(current.element).childNodes; for (var i=0; i element that contains the - * template directive and all property bindings needed for the template directive. + * Splits views at `