Skip to content

Commit

Permalink
fixup! fix(ivy): allow root components to inject ViewContainerRef
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Oct 23, 2018
1 parent 84d3062 commit 3e3a61e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/render3/interfaces/container.ts
Expand Up @@ -7,7 +7,7 @@
*/

import {LQueries} from './query';
import {RComment, RElement, RNode} from './renderer';
import {RComment, RElement} from './renderer';
import {StylingContext} from './styling';
import {HOST, LViewData, NEXT, PARENT, QUERIES} from './view';

Expand Down Expand Up @@ -100,10 +100,10 @@ export interface LContainer extends Array<any> {
* When views are inserted into `LContainer` then `renderParent` is:
* - `null`, we are in a view, keep going up a hierarchy until actual
* `renderParent` is found.
* - not `null`, then use the `projectedParent.native` as the `RNode` to insert
* - not `null`, then use the `projectedParent.native` as the `RElement` to insert
* views into.
*/
[RENDER_PARENT]: RNode|null;
[RENDER_PARENT]: RElement|null;
}

// Note: This hack is necessary so we don't erroneously get a circular dependency
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/render3/interfaces/renderer.ts
Expand Up @@ -68,10 +68,10 @@ export interface ProceduralRenderer3 {
destroyNode?: ((node: RNode) => void)|null;
appendChild(parent: RElement, newChild: RNode): void;
insertBefore(parent: RNode, newChild: RNode, refChild: RNode|null): void;
removeChild(parent: RNode, oldChild: RNode): void;
removeChild(parent: RElement, oldChild: RNode): void;
selectRootElement(selectorOrNode: string|any): RElement;

parentNode(node: RNode): RNode|null;
parentNode(node: RNode): RElement|null;
nextSibling(node: RNode): RNode|null;

setAttribute(el: RElement, name: string, value: string, namespace?: string|null): void;
Expand All @@ -97,7 +97,7 @@ export interface RendererFactory3 {

export const domRendererFactory3: RendererFactory3 = {
createRenderer: (hostElement: RElement | null, rendererType: RendererType2 | null):
Renderer3 => { return document as ObjectOrientedRenderer3;}
Renderer3 => { return document;}
};

/** Subset of API needed for appending elements and text nodes. */
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/render3/node_manipulation.ts
Expand Up @@ -53,7 +53,7 @@ export function getLContainer(tNode: TViewNode, embeddedView: LViewData): LConta
* Retrieves render parent for a given view.
* Might be null if a view is not yet attached to any container.
*/
export function getContainerRenderParent(tViewNode: TViewNode, view: LViewData): RNode|null {
export function getContainerRenderParent(tViewNode: TViewNode, view: LViewData): RElement|null {
const container = getLContainer(tViewNode, view);
return container ? container[RENDER_PARENT] : null;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ const projectionNodeStack: (LViewData | TNode)[] = [];
*/
function walkTNodeTree(
viewToWalk: LViewData, action: WalkTNodeTreeAction, renderer: Renderer3,
renderParent: RNode | null, beforeNode?: RNode | null) {
renderParent: RElement | null, beforeNode?: RNode | null) {
const rootTNode = viewToWalk[TVIEW].node as TViewNode;
let projectionNodeIndex = -1;
let currentView = viewToWalk;
Expand Down Expand Up @@ -203,7 +203,7 @@ export function findComponentView(lViewData: LViewData): LViewData {
* being passed as an argument.
*/
function executeNodeAction(
action: WalkTNodeTreeAction, renderer: Renderer3, parent: RNode | null,
action: WalkTNodeTreeAction, renderer: Renderer3, parent: RElement | null,
node: RComment | RElement | RText, beforeNode?: RNode | null) {
if (action === WalkTNodeTreeAction.Insert) {
isProceduralRenderer(renderer !) ?
Expand Down Expand Up @@ -499,7 +499,7 @@ function executePipeOnDestroys(viewData: LViewData): void {
}
}

export function getRenderParent(tNode: TNode, currentView: LViewData): RNode|null {
export function getRenderParent(tNode: TNode, currentView: LViewData): RElement|null {
if (canInsertNativeNode(tNode, currentView)) {
// If we are asked for a render parent of the root component we need to do low-level DOM
// operation as LTree doesn't exist above the topmost host node. We might need to find a render
Expand Down Expand Up @@ -600,7 +600,7 @@ export function canInsertNativeNode(tNode: TNode, currentView: LViewData): boole
* actual renderer being used.
*/
export function nativeInsertBefore(
renderer: Renderer3, parent: RNode, child: RNode, beforeNode: RNode | null): void {
renderer: Renderer3, parent: RElement, child: RNode, beforeNode: RNode | null): void {
if (isProceduralRenderer(renderer)) {
renderer.insertBefore(parent, child, beforeNode);
} else {
Expand All @@ -611,8 +611,8 @@ export function nativeInsertBefore(
/**
* Returns a native parent of a given native node.
*/
export function nativeParentNode(renderer: Renderer3, node: RNode): RNode|null {
return isProceduralRenderer(renderer) ? renderer.parentNode(node) : node.parentNode;
export function nativeParentNode(renderer: Renderer3, node: RNode): RElement|null {
return (isProceduralRenderer(renderer) ? renderer.parentNode(node) : node.parentNode) as RElement;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/render3/integration_spec.ts
Expand Up @@ -2511,7 +2511,7 @@ class MockRenderer implements ProceduralRenderer3 {
selectRootElement(selectorOrNode: string|any): RElement {
return ({} as any);
}
parentNode(node: RNode): RNode|null { return node.parentNode; }
parentNode(node: RNode): RElement|null { return node.parentNode as RElement; }
nextSibling(node: RNode): RNode|null { return node.nextSibling; }
setAttribute(el: RElement, name: string, value: string, namespace?: string|null): void {}
removeAttribute(el: RElement, name: string, namespace?: string|null): void {}
Expand Down

0 comments on commit 3e3a61e

Please sign in to comment.