perf(ivy): removes generation of comments (#21638)

PR Close #21638
This commit is contained in:
David-Emmanuel Divernois
2018-01-25 15:32:21 +01:00
committed by Misko Hevery
parent ede9cb7c2f
commit 1278cca883
11 changed files with 481 additions and 118 deletions

View File

@ -9,6 +9,7 @@
import {ComponentTemplate} from './definition';
import {LElementNode, LViewNode} from './node';
import {LQuery} from './query';
import {RNode} from './renderer';
import {LView, TView} from './view';
@ -80,6 +81,15 @@ export interface LContainer {
* this container are reported to queries referenced here.
*/
query: LQuery|null;
/*
* 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).
*/
nextNative: RNode|null|undefined;
}
/**

View File

@ -11,7 +11,7 @@ import {DirectiveDef} from './definition';
import {LInjector} from './injector';
import {LProjection} from './projection';
import {LQuery} from './query';
import {RComment, RElement, RText} from './renderer';
import {RElement, RText} from './renderer';
import {LView, TData, TView} from './view';
@ -74,9 +74,8 @@ export interface LNode {
* The associated DOM node. Storing this allows us to:
* - 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
* - mark locations where child views should be inserted (for containers)
*/
readonly native: RElement|RText|RComment|null;
readonly native: RElement|RText|null;
/**
* We need a reference to a node's parent so we can append the node to its parent's native
@ -122,6 +121,14 @@ export interface LNode {
*/
query: LQuery|null;
/**
* If this node is projected, pointer to the next node in the same projection parent
* (which is a container, an element, or a text node), or to the parent projection node
* if this is the last node in the projection.
* If this node is not projected, this field is null.
*/
pNextOrParent: LNode|null;
/**
* Pointer to the corresponding TNode object, which stores static
* data about this node.
@ -170,14 +177,7 @@ export interface LViewNode extends LNode {
/** Abstract node container which contains other views. */
export interface LContainerNode extends LNode {
/**
* 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.
*/
readonly native: RComment;
readonly native: null;
readonly data: LContainer;
child: null;
next: LContainerNode|LElementNode|LTextNode|LProjectionNode|null;

View File

@ -9,14 +9,13 @@
import {LContainerNode, LElementNode, LTextNode} from './node';
/**
* An LProjection is just an array of projected nodes.
*
* It would be nice if we could not need an array, but since a projected node can be
* re-projected, the same node can be part of more than one LProjectionNode which makes
* list approach not possible.
* An LProjection is a pointer to the first and the last projected nodes.
* It is a linked list (using the pNextOrParent property).
*/
export type LProjection = Array<LElementNode|LTextNode|LContainerNode>;
export interface LProjection {
first: LElementNode|LTextNode|LContainerNode|null;
last: LElementNode|LTextNode|LContainerNode|null;
}
/**
* Parsed selector in the following format:

View File

@ -35,7 +35,6 @@ export type Renderer3 = ObjectOrientedRenderer3 | ProceduralRenderer3;
* (reducing payload size).
* */
export interface ObjectOrientedRenderer3 {
createComment(data: string): RComment;
createElement(tagName: string): RElement;
createTextNode(data: string): RText;
@ -52,7 +51,6 @@ export interface ObjectOrientedRenderer3 {
export interface ProceduralRenderer3 {
destroy(): void;
createElement(name: string, namespace?: string|null): RElement;
createComment(value: string): RComment;
createText(value: string): RText;
/**
* This property is allowed to be null / undefined,
@ -138,8 +136,6 @@ 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;