@ -8,7 +8,7 @@
|
||||
import {CharCode} from '../../util/char_code';
|
||||
import {AttributeMarker, TAttributes} from '../interfaces/node';
|
||||
import {CssSelector} from '../interfaces/projection';
|
||||
import {ProceduralRenderer3, RElement, Renderer3, isProceduralRenderer} from '../interfaces/renderer';
|
||||
import {isProceduralRenderer, ProceduralRenderer3, RElement, Renderer3} from '../interfaces/renderer';
|
||||
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ export function setUpAttributes(renderer: Renderer3, native: RElement, attrs: TA
|
||||
* @param marker The attribute marker to test.
|
||||
* @returns true if the marker is a "name-only" marker (e.g. `Bindings`, `Template` or `I18n`).
|
||||
*/
|
||||
export function isNameOnlyAttributeMarker(marker: string | AttributeMarker | CssSelector) {
|
||||
export function isNameOnlyAttributeMarker(marker: string|AttributeMarker|CssSelector) {
|
||||
return marker === AttributeMarker.Bindings || marker === AttributeMarker.Template ||
|
||||
marker === AttributeMarker.I18n;
|
||||
}
|
||||
@ -116,7 +116,7 @@ export function isAnimationProp(name: string): boolean {
|
||||
* @param dst Location of where the merged `TAttributes` should end up.
|
||||
* @param src `TAttributes` which should be appended to `dst`
|
||||
*/
|
||||
export function mergeHostAttrs(dst: TAttributes | null, src: TAttributes | null): TAttributes|null {
|
||||
export function mergeHostAttrs(dst: TAttributes|null, src: TAttributes|null): TAttributes|null {
|
||||
if (src === null || src.length === 0) {
|
||||
// do nothing
|
||||
} else if (dst === null || dst.length === 0) {
|
||||
@ -156,8 +156,8 @@ export function mergeHostAttrs(dst: TAttributes | null, src: TAttributes | null)
|
||||
* @param value Value to add or to overwrite to `TAttributes` Only used if `marker` is not Class.
|
||||
*/
|
||||
export function mergeHostAttribute(
|
||||
dst: TAttributes, marker: AttributeMarker, key1: string, key2: string | null,
|
||||
value: string | null): void {
|
||||
dst: TAttributes, marker: AttributeMarker, key1: string, key2: string|null,
|
||||
value: string|null): void {
|
||||
let i = 0;
|
||||
// Assume that new markers will be inserted at the end.
|
||||
let markerInsertPosition = dst.length;
|
||||
@ -195,7 +195,7 @@ export function mergeHostAttribute(
|
||||
}
|
||||
return;
|
||||
} else if (key2 === dst[i + 1]) {
|
||||
dst[i + 2] = value !;
|
||||
dst[i + 2] = value!;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,13 @@ import {Injector} from '../../di/injector';
|
||||
import {assertLView} from '../assert';
|
||||
import {discoverLocalRefs, getComponentAtNodeIndex, getDirectivesAtNodeIndex, getLContext} from '../context_discovery';
|
||||
import {NodeInjector} from '../di';
|
||||
import {DebugNode, buildDebugNode} from '../instructions/lview_debug';
|
||||
import {buildDebugNode, DebugNode} from '../instructions/lview_debug';
|
||||
import {LContext} from '../interfaces/context';
|
||||
import {DirectiveDef} from '../interfaces/definition';
|
||||
import {TElementNode, TNode, TNodeProviderIndexes} from '../interfaces/node';
|
||||
import {isLView} from '../interfaces/type_checks';
|
||||
import {CLEANUP, CONTEXT, FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, TVIEW, T_HOST} from '../interfaces/view';
|
||||
import {CLEANUP, CONTEXT, FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, T_HOST, TVIEW} from '../interfaces/view';
|
||||
|
||||
import {stringifyForError} from './misc_utils';
|
||||
import {getLViewParent, getRootContext} from './view_traversal_utils';
|
||||
import {getTNode, unwrapRNode} from './view_utils';
|
||||
@ -93,14 +94,14 @@ export function getContext<T>(element: Element): T|null {
|
||||
* @publicApi
|
||||
* @globalApi ng
|
||||
*/
|
||||
export function getOwningComponent<T>(elementOrDir: Element | {}): T|null {
|
||||
export function getOwningComponent<T>(elementOrDir: Element|{}): T|null {
|
||||
const context = loadLContext(elementOrDir, false);
|
||||
if (context === null) return null;
|
||||
|
||||
let lView = context.lView;
|
||||
let parent: LView|null;
|
||||
ngDevMode && assertLView(lView);
|
||||
while (lView[HOST] === null && (parent = getLViewParent(lView) !)) {
|
||||
while (lView[HOST] === null && (parent = getLViewParent(lView)!)) {
|
||||
// As long as lView[HOST] is null we know we are part of sub-template such as `*ngIf`
|
||||
lView = parent;
|
||||
}
|
||||
@ -118,7 +119,7 @@ export function getOwningComponent<T>(elementOrDir: Element | {}): T|null {
|
||||
* @publicApi
|
||||
* @globalApi ng
|
||||
*/
|
||||
export function getRootComponents(elementOrDir: Element | {}): {}[] {
|
||||
export function getRootComponents(elementOrDir: Element|{}): {}[] {
|
||||
return [...getRootContext(elementOrDir).components];
|
||||
}
|
||||
|
||||
@ -132,7 +133,7 @@ export function getRootComponents(elementOrDir: Element | {}): {}[] {
|
||||
* @publicApi
|
||||
* @globalApi ng
|
||||
*/
|
||||
export function getInjector(elementOrDir: Element | {}): Injector {
|
||||
export function getInjector(elementOrDir: Element|{}): Injector {
|
||||
const context = loadLContext(elementOrDir, false);
|
||||
if (context === null) return Injector.NULL;
|
||||
|
||||
@ -192,7 +193,7 @@ export function getInjectionTokens(element: Element): any[] {
|
||||
* @globalApi ng
|
||||
*/
|
||||
export function getDirectives(element: Element): {}[] {
|
||||
const context = loadLContext(element) !;
|
||||
const context = loadLContext(element)!;
|
||||
|
||||
if (context.directives === undefined) {
|
||||
context.directives = getDirectivesAtNodeIndex(context.nodeIndex, context.lView, false);
|
||||
@ -250,7 +251,7 @@ export function getLocalRefs(target: {}): {[key: string]: any} {
|
||||
* @globalApi ng
|
||||
*/
|
||||
export function getHostElement(componentOrDirective: {}): Element {
|
||||
return getLContext(componentOrDirective) !.native as never as Element;
|
||||
return getLContext(componentOrDirective)!.native as never as Element;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,7 +271,7 @@ export function getRenderedText(component: any): string {
|
||||
|
||||
export function loadLContextFromNode(node: Node): LContext {
|
||||
if (!(node instanceof Node)) throw new Error('Expecting instance of DOM Element');
|
||||
return loadLContext(node) !;
|
||||
return loadLContext(node)!;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ export function getParentInjectorView(location: RelativeInjectorLocation, startV
|
||||
// <ng-template> tags or inline views, where the parent injector might live many views
|
||||
// above the child injector.
|
||||
while (viewOffset > 0) {
|
||||
parentView = parentView[DECLARATION_VIEW] !;
|
||||
parentView = parentView[DECLARATION_VIEW]!;
|
||||
viewOffset--;
|
||||
}
|
||||
return parentView;
|
||||
|
@ -37,16 +37,18 @@ export function stringifyForError(value: any): string {
|
||||
|
||||
|
||||
export const defaultScheduler =
|
||||
(() =>
|
||||
(typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame || // browser only
|
||||
setTimeout // everything else
|
||||
).bind(global))();
|
||||
(() => (
|
||||
typeof requestAnimationFrame !== 'undefined' &&
|
||||
requestAnimationFrame || // browser only
|
||||
setTimeout // everything else
|
||||
)
|
||||
.bind(global))();
|
||||
|
||||
/**
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵresolveWindow(element: RElement & {ownerDocument: Document}) {
|
||||
export function ɵɵresolveWindow(element: RElement&{ownerDocument: Document}) {
|
||||
return {name: 'window', target: element.ownerDocument.defaultView};
|
||||
}
|
||||
|
||||
@ -54,7 +56,7 @@ export function ɵɵresolveWindow(element: RElement & {ownerDocument: Document})
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵresolveDocument(element: RElement & {ownerDocument: Document}) {
|
||||
export function ɵɵresolveDocument(element: RElement&{ownerDocument: Document}) {
|
||||
return {name: 'document', target: element.ownerDocument};
|
||||
}
|
||||
|
||||
@ -62,7 +64,7 @@ export function ɵɵresolveDocument(element: RElement & {ownerDocument: Document
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵresolveBody(element: RElement & {ownerDocument: Document}) {
|
||||
export function ɵɵresolveBody(element: RElement&{ownerDocument: Document}) {
|
||||
return {name: 'body', target: element.ownerDocument.body};
|
||||
}
|
||||
|
||||
@ -85,7 +87,7 @@ export const INTERPOLATION_DELIMITER = `<60>`;
|
||||
/**
|
||||
* Unwrap a value which might be behind a closure (for forward declaration reasons).
|
||||
*/
|
||||
export function maybeUnwrapFn<T>(value: T | (() => T)): T {
|
||||
export function maybeUnwrapFn<T>(value: T|(() => T)): T {
|
||||
if (value instanceof Function) {
|
||||
return value();
|
||||
} else {
|
||||
|
@ -21,7 +21,7 @@ import {readPatchedLView} from './view_utils';
|
||||
export function getLViewParent(lView: LView): LView|null {
|
||||
ngDevMode && assertLView(lView);
|
||||
const parent = lView[PARENT];
|
||||
return isLContainer(parent) ? parent[PARENT] ! : parent;
|
||||
return isLContainer(parent) ? parent[PARENT]! : parent;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,11 +30,11 @@ export function getLViewParent(lView: LView): LView|null {
|
||||
*
|
||||
* @param componentOrLView any component or `LView`
|
||||
*/
|
||||
export function getRootView(componentOrLView: LView | {}): LView {
|
||||
export function getRootView(componentOrLView: LView|{}): LView {
|
||||
ngDevMode && assertDefined(componentOrLView, 'component');
|
||||
let lView = isLView(componentOrLView) ? componentOrLView : readPatchedLView(componentOrLView) !;
|
||||
let lView = isLView(componentOrLView) ? componentOrLView : readPatchedLView(componentOrLView)!;
|
||||
while (lView && !(lView[FLAGS] & LViewFlags.IsRoot)) {
|
||||
lView = getLViewParent(lView) !;
|
||||
lView = getLViewParent(lView)!;
|
||||
}
|
||||
ngDevMode && assertLView(lView);
|
||||
return lView;
|
||||
@ -47,7 +47,7 @@ export function getRootView(componentOrLView: LView | {}): LView {
|
||||
*
|
||||
* @param viewOrComponent the `LView` or component to get the root context for.
|
||||
*/
|
||||
export function getRootContext(viewOrComponent: LView | {}): RootContext {
|
||||
export function getRootContext(viewOrComponent: LView|{}): RootContext {
|
||||
const rootView = getRootView(viewOrComponent);
|
||||
ngDevMode &&
|
||||
assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');
|
||||
|
@ -11,7 +11,7 @@ import {assertTNodeForLView} from '../assert';
|
||||
import {ACTIVE_INDEX, ActiveIndexFlag, LContainer, TYPE} from '../interfaces/container';
|
||||
import {LContext, MONKEY_PATCH_KEY_NAME} from '../interfaces/context';
|
||||
import {TConstants, TNode} from '../interfaces/node';
|
||||
import {RNode, isProceduralRenderer} from '../interfaces/renderer';
|
||||
import {isProceduralRenderer, RNode} from '../interfaces/renderer';
|
||||
import {isLContainer, isLView} from '../interfaces/type_checks';
|
||||
import {FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, PARENT, PREORDER_HOOK_FLAGS, RENDERER, TData, TView} from '../interfaces/view';
|
||||
|
||||
@ -38,7 +38,7 @@ import {FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, PARENT, PREORDER_HOOK_FLA
|
||||
* Returns `RNode`.
|
||||
* @param value wrapped value of `RNode`, `LView`, `LContainer`
|
||||
*/
|
||||
export function unwrapRNode(value: RNode | LView | LContainer): RNode {
|
||||
export function unwrapRNode(value: RNode|LView|LContainer): RNode {
|
||||
while (Array.isArray(value)) {
|
||||
value = value[HOST] as any;
|
||||
}
|
||||
@ -49,7 +49,7 @@ export function unwrapRNode(value: RNode | LView | LContainer): RNode {
|
||||
* Returns `LView` or `null` if not found.
|
||||
* @param value wrapped value of `RNode`, `LView`, `LContainer`
|
||||
*/
|
||||
export function unwrapLView(value: RNode | LView | LContainer): LView|null {
|
||||
export function unwrapLView(value: RNode|LView|LContainer): LView|null {
|
||||
while (Array.isArray(value)) {
|
||||
// This check is same as `isLView()` but we don't call at as we don't want to call
|
||||
// `Array.isArray()` twice and give JITer more work for inlining.
|
||||
@ -63,7 +63,7 @@ export function unwrapLView(value: RNode | LView | LContainer): LView|null {
|
||||
* Returns `LContainer` or `null` if not found.
|
||||
* @param value wrapped value of `RNode`, `LView`, `LContainer`
|
||||
*/
|
||||
export function unwrapLContainer(value: RNode | LView | LContainer): LContainer|null {
|
||||
export function unwrapLContainer(value: RNode|LView|LContainer): LContainer|null {
|
||||
while (Array.isArray(value)) {
|
||||
// This check is same as `isLContainer()` but we don't call at as we don't want to call
|
||||
// `Array.isArray()` twice and give JITer more work for inlining.
|
||||
@ -124,7 +124,7 @@ export function getTNode(tView: TView, index: number): TNode {
|
||||
}
|
||||
|
||||
/** Retrieves a value from any `LView` or `TData`. */
|
||||
export function load<T>(view: LView | TData, index: number): T {
|
||||
export function load<T>(view: LView|TData, index: number): T {
|
||||
ngDevMode && assertDataInRange(view, index + HEADER_OFFSET);
|
||||
return view[index + HEADER_OFFSET];
|
||||
}
|
||||
@ -176,8 +176,7 @@ export function viewAttachedToContainer(view: LView): boolean {
|
||||
}
|
||||
|
||||
/** Returns a constant from `TConstants` instance. */
|
||||
export function getConstant<T>(consts: TConstants | null, index: number | null | undefined): T|
|
||||
null {
|
||||
export function getConstant<T>(consts: TConstants|null, index: number|null|undefined): T|null {
|
||||
return consts === null || index == null ? null : consts[index] as unknown as T;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user