refactor(ivy): use comment nodes to mark view containers (#24346)

PR Close #24346
This commit is contained in:
Marc Laval
2018-06-06 17:30:48 +02:00
committed by Miško Hevery
parent 153ba4dff3
commit e3c54e4465
11 changed files with 191 additions and 178 deletions

View File

@ -10,7 +10,7 @@ import {LContainer} from './container';
import {LInjector} from './injector';
import {LProjection} from './projection';
import {LQueries} from './query';
import {RElement, RText} from './renderer';
import {RComment, RElement, RText} from './renderer';
import {LViewData, TView} from './view';
@ -63,7 +63,7 @@ export interface LNode {
* - append children to their element parents in the DOM (e.g. `parent.native.appendChild(...)`)
* - retrieve the sibling elements of text nodes whose creation / insertion has been delayed
*/
readonly native: RElement|RText|null|undefined;
readonly native: RComment|RElement|RText|null;
/**
* If regular LElementNode, then `data` will be null.
@ -141,13 +141,13 @@ export interface LViewNode extends LNode {
/** Abstract node container which contains other views. */
export interface LContainerNode extends LNode {
/*
* Caches the reference of the first native node following this container in the same native
* parent.
* This is reset to undefined in containerRefreshEnd.
* When it is undefined, it means the value has not been computed yet.
* Otherwise, it contains the result of findBeforeNode(container, null).
* This comment node is appended to the container's parent element to mark where
* in the DOM the container's child views should be added.
*
* If the container is a root node of a view, this comment will not be appended
* until the parent view is processed.
*/
native: RElement|RText|null|undefined;
native: RComment;
readonly data: LContainer;
}

View File

@ -35,6 +35,7 @@ export type Renderer3 = ObjectOrientedRenderer3 | ProceduralRenderer3;
* (reducing payload size).
* */
export interface ObjectOrientedRenderer3 {
createComment(data: string): RComment;
createElement(tagName: string): RElement;
createElementNS(namespace: string, tagName: string): RElement;
createTextNode(data: string): RText;
@ -57,6 +58,7 @@ export function isProceduralRenderer(renderer: ProceduralRenderer3 | ObjectOrien
*/
export interface ProceduralRenderer3 {
destroy(): void;
createComment(value: string): RComment;
createElement(name: string, namespace?: string|null): RElement;
createText(value: string): RText;
/**
@ -144,6 +146,8 @@ export interface RDomTokenList {
export interface RText extends RNode { textContent: string|null; }
export interface RComment extends RNode {}
// Note: This hack is necessary so we don't erroneously get a circular dependency
// failure based on types.
export const unusedValueExportToPlacateAjd = 1;