2018-10-18 09:23:18 +02:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2019-05-28 10:31:01 -07:00
|
|
|
import {StyleSanitizeFn} from '../sanitization/style_sanitizer';
|
|
|
|
import {assertDefined} from '../util/assert';
|
2019-01-30 23:42:26 +00:00
|
|
|
|
2019-01-28 14:45:31 -08:00
|
|
|
import {assertLViewOrUndefined} from './assert';
|
2018-11-27 12:05:26 -08:00
|
|
|
import {ComponentDef, DirectiveDef} from './interfaces/definition';
|
2019-02-06 11:56:57 +01:00
|
|
|
import {TElementNode, TNode, TViewNode} from './interfaces/node';
|
2019-08-02 16:43:10 +02:00
|
|
|
import {CONTEXT, DECLARATION_VIEW, LView, OpaqueViewState, TVIEW} from './interfaces/view';
|
2019-09-09 13:14:26 -07:00
|
|
|
import {resetStylingState} from './styling_next/state';
|
2018-10-18 09:23:18 +02:00
|
|
|
|
2019-01-28 14:45:31 -08:00
|
|
|
|
2018-10-18 09:23:18 +02:00
|
|
|
/**
|
|
|
|
* Store the element depth count. This is used to identify the root elements of the template
|
2018-11-21 21:14:06 -08:00
|
|
|
* so that we can than attach `LView` to only those elements.
|
2018-10-18 09:23:18 +02:00
|
|
|
*/
|
|
|
|
let elementDepthCount !: number;
|
|
|
|
|
|
|
|
export function getElementDepthCount() {
|
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
|
|
|
return elementDepthCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function increaseElementDepthCount() {
|
|
|
|
elementDepthCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function decreaseElementDepthCount() {
|
|
|
|
elementDepthCount--;
|
|
|
|
}
|
|
|
|
|
2018-11-27 12:05:26 -08:00
|
|
|
let currentDirectiveDef: DirectiveDef<any>|ComponentDef<any>|null = null;
|
|
|
|
|
|
|
|
export function getCurrentDirectiveDef(): DirectiveDef<any>|ComponentDef<any>|null {
|
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
|
|
|
return currentDirectiveDef;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setCurrentDirectiveDef(def: DirectiveDef<any>| ComponentDef<any>| null): void {
|
|
|
|
currentDirectiveDef = def;
|
|
|
|
}
|
|
|
|
|
2018-10-18 09:23:18 +02:00
|
|
|
/**
|
|
|
|
* Stores whether directives should be matched to elements.
|
|
|
|
*
|
|
|
|
* When template contains `ngNonBindable` than we need to prevent the runtime form matching
|
|
|
|
* directives on children of that element.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* ```
|
|
|
|
* <my-comp my-directive>
|
|
|
|
* Should match component / directive.
|
|
|
|
* </my-comp>
|
|
|
|
* <div ngNonBindable>
|
|
|
|
* <my-comp my-directive>
|
|
|
|
* Should not match component / directive because we are in ngNonBindable.
|
|
|
|
* </my-comp>
|
|
|
|
* </div>
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
let bindingsEnabled !: boolean;
|
|
|
|
|
|
|
|
export function getBindingsEnabled(): boolean {
|
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
|
|
|
return bindingsEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables directive matching on elements.
|
|
|
|
*
|
|
|
|
* * Example:
|
|
|
|
* ```
|
|
|
|
* <my-comp my-directive>
|
|
|
|
* Should match component / directive.
|
|
|
|
* </my-comp>
|
|
|
|
* <div ngNonBindable>
|
2019-05-17 18:49:21 -07:00
|
|
|
* <!-- ɵɵdisableBindings() -->
|
2018-10-18 09:23:18 +02:00
|
|
|
* <my-comp my-directive>
|
|
|
|
* Should not match component / directive because we are in ngNonBindable.
|
|
|
|
* </my-comp>
|
2019-05-17 18:49:21 -07:00
|
|
|
* <!-- ɵɵenableBindings() -->
|
2018-10-18 09:23:18 +02:00
|
|
|
* </div>
|
|
|
|
* ```
|
2019-04-04 11:41:52 -07:00
|
|
|
*
|
2019-04-10 13:45:26 -07:00
|
|
|
* @codeGenApi
|
2018-10-18 09:23:18 +02:00
|
|
|
*/
|
2019-05-17 18:49:21 -07:00
|
|
|
export function ɵɵenableBindings(): void {
|
2018-10-18 09:23:18 +02:00
|
|
|
bindingsEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disables directive matching on element.
|
|
|
|
*
|
|
|
|
* * Example:
|
|
|
|
* ```
|
|
|
|
* <my-comp my-directive>
|
|
|
|
* Should match component / directive.
|
|
|
|
* </my-comp>
|
|
|
|
* <div ngNonBindable>
|
2019-05-17 18:49:21 -07:00
|
|
|
* <!-- ɵɵdisableBindings() -->
|
2018-10-18 09:23:18 +02:00
|
|
|
* <my-comp my-directive>
|
|
|
|
* Should not match component / directive because we are in ngNonBindable.
|
|
|
|
* </my-comp>
|
2019-05-17 18:49:21 -07:00
|
|
|
* <!-- ɵɵenableBindings() -->
|
2018-10-18 09:23:18 +02:00
|
|
|
* </div>
|
|
|
|
* ```
|
2019-04-04 11:41:52 -07:00
|
|
|
*
|
2019-04-10 13:45:26 -07:00
|
|
|
* @codeGenApi
|
2018-10-18 09:23:18 +02:00
|
|
|
*/
|
2019-05-17 18:49:21 -07:00
|
|
|
export function ɵɵdisableBindings(): void {
|
2018-10-18 09:23:18 +02:00
|
|
|
bindingsEnabled = false;
|
|
|
|
}
|
|
|
|
|
2018-11-21 21:14:06 -08:00
|
|
|
export function getLView(): LView {
|
|
|
|
return lView;
|
2018-11-13 09:36:30 +01:00
|
|
|
}
|
|
|
|
|
2019-04-02 16:16:00 -07:00
|
|
|
/**
|
|
|
|
* Used as the starting directive id value.
|
|
|
|
*
|
|
|
|
* All subsequent directives are incremented from this value onwards.
|
|
|
|
* The reason why this value is `1` instead of `0` is because the `0`
|
|
|
|
* value is reserved for the template.
|
|
|
|
*/
|
2019-09-09 13:14:26 -07:00
|
|
|
let activeDirectiveId = 0;
|
2019-04-02 16:16:00 -07:00
|
|
|
|
2019-09-09 13:14:26 -07:00
|
|
|
/**
|
|
|
|
* Flags used for an active element during change detection.
|
|
|
|
*
|
|
|
|
* These flags are used within other instructions to inform cleanup or
|
|
|
|
* exit operations to run when an element is being processed.
|
|
|
|
*
|
|
|
|
* Note that these flags are reset each time an element changes (whether it
|
|
|
|
* happens when `advance()` is run or when change detection exits out of a template
|
|
|
|
* function or when all host bindings are processed for an element).
|
|
|
|
*/
|
|
|
|
export const enum ActiveElementFlags {
|
|
|
|
Initial = 0b00,
|
|
|
|
RunExitFn = 0b01,
|
|
|
|
ResetStylesOnExit = 0b10,
|
|
|
|
Size = 2,
|
|
|
|
}
|
2019-04-02 16:16:00 -07:00
|
|
|
|
|
|
|
/**
|
2019-09-09 13:14:26 -07:00
|
|
|
* Determines whether or not a flag is currently set for the active element.
|
2019-04-02 16:16:00 -07:00
|
|
|
*/
|
2019-09-09 13:14:26 -07:00
|
|
|
export function hasActiveElementFlag(flag: ActiveElementFlags) {
|
|
|
|
return (_selectedIndex & flag) === flag;
|
|
|
|
}
|
2019-04-02 16:16:00 -07:00
|
|
|
|
|
|
|
/**
|
2019-09-09 13:14:26 -07:00
|
|
|
* Sets a flag is for the active element.
|
2019-04-02 16:16:00 -07:00
|
|
|
*/
|
2019-09-09 13:14:26 -07:00
|
|
|
export function setActiveElementFlag(flag: ActiveElementFlags) {
|
|
|
|
_selectedIndex |= flag;
|
|
|
|
}
|
2019-04-02 16:16:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the active directive host element and resets the directive id value
|
|
|
|
* (when the provided elementIndex value has changed).
|
|
|
|
*
|
|
|
|
* @param elementIndex the element index value for the host element where
|
|
|
|
* the directive/component instance lives
|
|
|
|
*/
|
|
|
|
export function setActiveHostElement(elementIndex: number | null = null) {
|
2019-09-09 13:14:26 -07:00
|
|
|
if (getSelectedIndex() !== elementIndex) {
|
|
|
|
if (hasActiveElementFlag(ActiveElementFlags.RunExitFn)) {
|
|
|
|
executeElementExitFn();
|
|
|
|
}
|
|
|
|
if (hasActiveElementFlag(ActiveElementFlags.ResetStylesOnExit)) {
|
|
|
|
resetStylingState();
|
|
|
|
}
|
2019-07-26 11:52:15 +02:00
|
|
|
setSelectedIndex(elementIndex === null ? -1 : elementIndex);
|
2019-09-09 13:14:26 -07:00
|
|
|
activeDirectiveId = 0;
|
2019-04-02 16:16:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 13:14:26 -07:00
|
|
|
let _elementExitFn: Function|null = null;
|
|
|
|
export function executeElementExitFn() {
|
|
|
|
_elementExitFn !();
|
|
|
|
// TODO (matsko|misko): remove this unassignment once the state management of
|
|
|
|
// global variables are better managed.
|
|
|
|
_selectedIndex &= ~ActiveElementFlags.RunExitFn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Queues a function to be run once the element is "exited" in CD.
|
|
|
|
*
|
|
|
|
* Change detection will focus on an element either when the `advance()`
|
|
|
|
* instruction is called or when the template or host bindings instruction
|
|
|
|
* code is invoked. The element is then "exited" when the next element is
|
|
|
|
* selected or when change detection for the template or host bindings is
|
|
|
|
* complete. When this occurs (the element change operation) then an exit
|
|
|
|
* function will be invoked if it has been set. This function can be used
|
|
|
|
* to assign that exit function.
|
|
|
|
*
|
|
|
|
* @param fn
|
|
|
|
*/
|
|
|
|
export function setElementExitFn(fn: Function): void {
|
|
|
|
setActiveElementFlag(ActiveElementFlags.RunExitFn);
|
|
|
|
_elementExitFn = fn;
|
|
|
|
}
|
|
|
|
|
2019-04-02 16:16:00 -07:00
|
|
|
/**
|
|
|
|
* Returns the current id value of the current directive.
|
|
|
|
*
|
|
|
|
* For example we have an element that has two directives on it:
|
|
|
|
* <div dir-one dir-two></div>
|
|
|
|
*
|
|
|
|
* dirOne->hostBindings() (id == 1)
|
|
|
|
* dirTwo->hostBindings() (id == 2)
|
|
|
|
*
|
|
|
|
* Note that this is only active when `hostBinding` functions are being processed.
|
|
|
|
*
|
|
|
|
* Note that directive id values are specific to an element (this means that
|
|
|
|
* the same id value could be present on another element with a completely
|
|
|
|
* different set of directives).
|
|
|
|
*/
|
|
|
|
export function getActiveDirectiveId() {
|
|
|
|
return activeDirectiveId;
|
|
|
|
}
|
2019-03-15 13:45:08 -07:00
|
|
|
|
|
|
|
/**
|
2019-04-02 16:16:00 -07:00
|
|
|
* Increments the current directive id value.
|
2019-03-15 13:45:08 -07:00
|
|
|
*
|
2019-04-02 16:16:00 -07:00
|
|
|
* For example we have an element that has two directives on it:
|
|
|
|
* <div dir-one dir-two></div>
|
|
|
|
*
|
|
|
|
* dirOne->hostBindings() (index = 1)
|
|
|
|
* // increment
|
|
|
|
* dirTwo->hostBindings() (index = 2)
|
|
|
|
*
|
|
|
|
* Depending on whether or not a previous directive had any inherited
|
|
|
|
* directives present, that value will be incremented in addition
|
|
|
|
* to the id jumping up by one.
|
|
|
|
*
|
|
|
|
* Note that this is only active when `hostBinding` functions are being processed.
|
|
|
|
*
|
|
|
|
* Note that directive id values are specific to an element (this means that
|
|
|
|
* the same id value could be present on another element with a completely
|
|
|
|
* different set of directives).
|
2019-03-15 13:45:08 -07:00
|
|
|
*/
|
2019-04-02 16:16:00 -07:00
|
|
|
export function incrementActiveDirectiveId() {
|
2019-09-09 13:14:26 -07:00
|
|
|
// Each directive gets a uniqueId value that is the same for both
|
|
|
|
// create and update calls when the hostBindings function is called. The
|
|
|
|
// directive uniqueId is not set anywhere--it is just incremented between
|
|
|
|
// each hostBindings call and is useful for helping instruction code
|
|
|
|
// uniquely determine which directive is currently active when executed.
|
|
|
|
activeDirectiveId += 1;
|
2019-03-15 13:45:08 -07:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:23:18 +02:00
|
|
|
/**
|
|
|
|
* Restores `contextViewData` to the given OpaqueViewState instance.
|
|
|
|
*
|
|
|
|
* Used in conjunction with the getCurrentView() instruction to save a snapshot
|
|
|
|
* of the current view and restore it when listeners are invoked. This allows
|
|
|
|
* walking the declaration view tree in listeners to get vars from parent views.
|
|
|
|
*
|
|
|
|
* @param viewToRestore The OpaqueViewState instance to restore.
|
2019-04-04 11:41:52 -07:00
|
|
|
*
|
2019-04-10 13:45:26 -07:00
|
|
|
* @codeGenApi
|
2018-10-18 09:23:18 +02:00
|
|
|
*/
|
2019-05-17 18:49:21 -07:00
|
|
|
export function ɵɵrestoreView(viewToRestore: OpaqueViewState) {
|
2018-11-21 21:14:06 -08:00
|
|
|
contextLView = viewToRestore as any as LView;
|
2018-10-18 09:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Used to set the parent property when nodes are created and track query results. */
|
|
|
|
let previousOrParentTNode: TNode;
|
|
|
|
|
|
|
|
export function getPreviousOrParentTNode(): TNode {
|
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
|
|
|
return previousOrParentTNode;
|
|
|
|
}
|
|
|
|
|
2019-05-14 21:47:11 -07:00
|
|
|
export function setPreviousOrParentTNode(tNode: TNode, _isParent: boolean) {
|
2018-10-18 09:23:18 +02:00
|
|
|
previousOrParentTNode = tNode;
|
2019-05-14 21:47:11 -07:00
|
|
|
isParent = _isParent;
|
2018-10-18 09:23:18 +02:00
|
|
|
}
|
|
|
|
|
2018-11-21 21:14:06 -08:00
|
|
|
export function setTNodeAndViewData(tNode: TNode, view: LView) {
|
2019-01-28 14:45:31 -08:00
|
|
|
ngDevMode && assertLViewOrUndefined(view);
|
2018-10-18 09:23:18 +02:00
|
|
|
previousOrParentTNode = tNode;
|
2018-11-21 21:14:06 -08:00
|
|
|
lView = view;
|
2018-10-18 09:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If `isParent` is:
|
|
|
|
* - `true`: then `previousOrParentTNode` points to a parent node.
|
|
|
|
* - `false`: then `previousOrParentTNode` points to previous node (sibling).
|
|
|
|
*/
|
|
|
|
let isParent: boolean;
|
|
|
|
|
|
|
|
export function getIsParent(): boolean {
|
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
|
|
|
return isParent;
|
|
|
|
}
|
|
|
|
|
2019-05-14 21:47:11 -07:00
|
|
|
export function setIsNotParent(): void {
|
|
|
|
isParent = false;
|
|
|
|
}
|
|
|
|
export function setIsParent(): void {
|
|
|
|
isParent = true;
|
2018-10-18 09:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State of the current view being processed.
|
|
|
|
*
|
|
|
|
* An array of nodes (text, element, container, etc), pipes, their bindings, and
|
|
|
|
* any local variables that need to be stored between invocations.
|
|
|
|
*/
|
2018-11-21 21:14:06 -08:00
|
|
|
let lView: LView;
|
2018-10-18 09:23:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The last viewData retrieved by nextContext().
|
|
|
|
* Allows building nextContext() and reference() calls.
|
|
|
|
*
|
|
|
|
* e.g. const inner = x().$implicit; const outer = x().$implicit;
|
|
|
|
*/
|
2018-11-21 21:14:06 -08:00
|
|
|
let contextLView: LView = null !;
|
2018-10-18 09:23:18 +02:00
|
|
|
|
2018-11-21 21:14:06 -08:00
|
|
|
export function getContextLView(): LView {
|
2018-10-18 09:23:18 +02:00
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
2018-11-21 21:14:06 -08:00
|
|
|
return contextLView;
|
2018-10-18 09:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* In this mode, any changes in bindings will throw an ExpressionChangedAfterChecked error.
|
|
|
|
*
|
|
|
|
* Necessary to support ChangeDetectorRef.checkNoChanges().
|
|
|
|
*/
|
|
|
|
let checkNoChangesMode = false;
|
|
|
|
|
|
|
|
export function getCheckNoChangesMode(): boolean {
|
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
|
|
|
return checkNoChangesMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setCheckNoChangesMode(mode: boolean): void {
|
|
|
|
checkNoChangesMode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The root index from which pure function instructions should calculate their binding
|
|
|
|
* indices. In component views, this is TView.bindingStartIndex. In a host binding
|
|
|
|
* context, this is the TView.expandoStartIndex + any dirs/hostVars before the given dir.
|
|
|
|
*/
|
|
|
|
let bindingRootIndex: number = -1;
|
|
|
|
|
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
|
|
|
export function getBindingRoot() {
|
|
|
|
return bindingRootIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setBindingRoot(value: number) {
|
|
|
|
bindingRootIndex = value;
|
|
|
|
}
|
|
|
|
|
2019-01-18 18:02:32 -08:00
|
|
|
/**
|
2019-01-23 11:54:43 -08:00
|
|
|
* Current index of a View or Content Query which needs to be processed next.
|
|
|
|
* We iterate over the list of Queries and increment current query index at every step.
|
2019-01-18 18:02:32 -08:00
|
|
|
*/
|
2019-01-23 11:54:43 -08:00
|
|
|
let currentQueryIndex: number = 0;
|
2019-01-18 18:02:32 -08:00
|
|
|
|
2019-01-23 11:54:43 -08:00
|
|
|
export function getCurrentQueryIndex(): number {
|
2019-01-18 18:02:32 -08:00
|
|
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
2019-01-23 11:54:43 -08:00
|
|
|
return currentQueryIndex;
|
2019-01-18 18:02:32 -08:00
|
|
|
}
|
|
|
|
|
2019-01-23 11:54:43 -08:00
|
|
|
export function setCurrentQueryIndex(value: number): void {
|
|
|
|
currentQueryIndex = value;
|
2019-01-18 18:02:32 -08:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:23:18 +02:00
|
|
|
/**
|
2019-08-22 11:43:24 +02:00
|
|
|
* Swap the current lView with a new lView.
|
2018-10-18 09:23:18 +02:00
|
|
|
*
|
2019-08-22 11:43:24 +02:00
|
|
|
* For performance reasons we store the lView in the top level of the module.
|
2018-10-18 09:23:18 +02:00
|
|
|
* This way we minimize the number of properties to read. Whenever a new view
|
2019-08-22 11:43:24 +02:00
|
|
|
* is entered we have to store the lView for later, and when the view is
|
2018-10-18 09:23:18 +02:00
|
|
|
* exited the state has to be restored
|
|
|
|
*
|
2019-08-22 11:43:24 +02:00
|
|
|
* @param newView New lView to become active
|
2018-10-18 09:23:18 +02:00
|
|
|
* @param host Element to which the View is a child of
|
2019-08-22 11:43:24 +02:00
|
|
|
* @returns the previously active lView;
|
2018-10-18 09:23:18 +02:00
|
|
|
*/
|
2019-08-22 11:43:24 +02:00
|
|
|
export function selectView(newView: LView, hostTNode: TElementNode | TViewNode | null): LView {
|
2019-01-28 14:45:31 -08:00
|
|
|
ngDevMode && assertLViewOrUndefined(newView);
|
2018-11-21 21:14:06 -08:00
|
|
|
const oldView = lView;
|
2018-10-18 09:23:18 +02:00
|
|
|
|
|
|
|
previousOrParentTNode = hostTNode !;
|
|
|
|
isParent = true;
|
|
|
|
|
2018-11-21 21:14:06 -08:00
|
|
|
lView = contextLView = newView;
|
2018-10-18 09:23:18 +02:00
|
|
|
return oldView;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function nextContextImpl<T = any>(level: number = 1): T {
|
2018-11-21 21:14:06 -08:00
|
|
|
contextLView = walkUpViews(level, contextLView !);
|
|
|
|
return contextLView[CONTEXT] as T;
|
2018-10-18 09:23:18 +02:00
|
|
|
}
|
|
|
|
|
2018-11-21 21:14:06 -08:00
|
|
|
function walkUpViews(nestingLevel: number, currentView: LView): LView {
|
2018-10-18 09:23:18 +02:00
|
|
|
while (nestingLevel > 0) {
|
|
|
|
ngDevMode && assertDefined(
|
|
|
|
currentView[DECLARATION_VIEW],
|
|
|
|
'Declaration view should be defined if nesting level is greater than 0.');
|
|
|
|
currentView = currentView[DECLARATION_VIEW] !;
|
|
|
|
nestingLevel--;
|
|
|
|
}
|
|
|
|
return currentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the application state.
|
|
|
|
*/
|
|
|
|
export function resetComponentState() {
|
|
|
|
isParent = false;
|
|
|
|
previousOrParentTNode = null !;
|
|
|
|
elementDepthCount = 0;
|
|
|
|
bindingsEnabled = true;
|
2019-05-28 10:31:01 -07:00
|
|
|
setCurrentStyleSanitizer(null);
|
2018-10-18 09:23:18 +02:00
|
|
|
}
|
|
|
|
|
2019-09-09 13:14:26 -07:00
|
|
|
/* tslint:disable */
|
|
|
|
let _selectedIndex = -1 << ActiveElementFlags.Size;
|
2019-03-26 14:57:36 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the most recent index passed to {@link select}
|
|
|
|
*
|
|
|
|
* Used with {@link property} instruction (and more in the future) to identify the index in the
|
|
|
|
* current `LView` to act on.
|
|
|
|
*/
|
|
|
|
export function getSelectedIndex() {
|
2019-09-09 13:14:26 -07:00
|
|
|
return _selectedIndex >> ActiveElementFlags.Size;
|
2019-03-26 14:57:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the most recent index passed to {@link select}
|
|
|
|
*
|
|
|
|
* Used with {@link property} instruction (and more in the future) to identify the index in the
|
|
|
|
* current `LView` to act on.
|
2019-09-09 13:14:26 -07:00
|
|
|
*
|
|
|
|
* (Note that if an "exit function" was set earlier (via `setElementExitFn()`) then that will be
|
|
|
|
* run if and when the provided `index` value is different from the current selected index value.)
|
2019-03-26 14:57:36 -07:00
|
|
|
*/
|
|
|
|
export function setSelectedIndex(index: number) {
|
2019-09-09 13:14:26 -07:00
|
|
|
_selectedIndex = index << ActiveElementFlags.Size;
|
2019-03-26 14:57:36 -07:00
|
|
|
}
|
2019-04-01 15:36:43 -07:00
|
|
|
|
|
|
|
|
|
|
|
let _currentNamespace: string|null = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the namespace used to create elements to `'http://www.w3.org/2000/svg'` in global state.
|
2019-04-04 11:41:52 -07:00
|
|
|
*
|
2019-04-10 13:45:26 -07:00
|
|
|
* @codeGenApi
|
2019-04-01 15:36:43 -07:00
|
|
|
*/
|
2019-05-17 18:49:21 -07:00
|
|
|
export function ɵɵnamespaceSVG() {
|
2019-04-01 15:36:43 -07:00
|
|
|
_currentNamespace = 'http://www.w3.org/2000/svg';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the namespace used to create elements to `'http://www.w3.org/1998/MathML/'` in global state.
|
2019-04-04 11:41:52 -07:00
|
|
|
*
|
2019-04-10 13:45:26 -07:00
|
|
|
* @codeGenApi
|
2019-04-01 15:36:43 -07:00
|
|
|
*/
|
2019-05-17 18:49:21 -07:00
|
|
|
export function ɵɵnamespaceMathML() {
|
2019-04-01 15:36:43 -07:00
|
|
|
_currentNamespace = 'http://www.w3.org/1998/MathML/';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-06-26 09:21:57 +02:00
|
|
|
* Sets the namespace used to create elements to `null`, which forces element creation to use
|
2019-04-01 15:36:43 -07:00
|
|
|
* `createElement` rather than `createElementNS`.
|
2019-04-04 11:41:52 -07:00
|
|
|
*
|
2019-04-10 13:45:26 -07:00
|
|
|
* @codeGenApi
|
2019-04-01 15:36:43 -07:00
|
|
|
*/
|
2019-05-17 18:49:21 -07:00
|
|
|
export function ɵɵnamespaceHTML() {
|
2019-06-26 09:21:57 +02:00
|
|
|
namespaceHTMLInternal();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the namespace used to create elements to `null`, which forces element creation to use
|
|
|
|
* `createElement` rather than `createElementNS`.
|
|
|
|
*/
|
|
|
|
export function namespaceHTMLInternal() {
|
2019-04-01 15:36:43 -07:00
|
|
|
_currentNamespace = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getNamespace(): string|null {
|
|
|
|
return _currentNamespace;
|
|
|
|
}
|
2019-05-28 10:31:01 -07:00
|
|
|
|
|
|
|
let _currentSanitizer: StyleSanitizeFn|null;
|
|
|
|
export function setCurrentStyleSanitizer(sanitizer: StyleSanitizeFn | null) {
|
|
|
|
_currentSanitizer = sanitizer;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getCurrentStyleSanitizer() {
|
|
|
|
return _currentSanitizer;
|
|
|
|
}
|