feat(ivy): add ɵɵtextInterpolateX instructions (#30011)
- `ɵɵtextBinding(..., ɵɵinterpolationX())` instructions will now just be `ɵɵtextInterpolate(...)` instructions PR Close #30011
This commit is contained in:
@ -57,6 +57,16 @@ export {
|
||||
ɵɵelement,
|
||||
ɵɵlistener,
|
||||
ɵɵtext,
|
||||
ɵɵtextInterpolate,
|
||||
ɵɵtextInterpolate1,
|
||||
ɵɵtextInterpolate2,
|
||||
ɵɵtextInterpolate3,
|
||||
ɵɵtextInterpolate4,
|
||||
ɵɵtextInterpolate5,
|
||||
ɵɵtextInterpolate6,
|
||||
ɵɵtextInterpolate7,
|
||||
ɵɵtextInterpolate8,
|
||||
ɵɵtextInterpolateV,
|
||||
ɵɵembeddedViewStart,
|
||||
ɵɵprojection,
|
||||
ɵɵbind,
|
||||
|
@ -107,7 +107,18 @@ export {
|
||||
ɵɵtemplate,
|
||||
|
||||
ɵɵtext,
|
||||
ɵɵtextBinding} from './instructions/all';
|
||||
ɵɵtextBinding,
|
||||
ɵɵtextInterpolate,
|
||||
ɵɵtextInterpolate1,
|
||||
ɵɵtextInterpolate2,
|
||||
ɵɵtextInterpolate3,
|
||||
ɵɵtextInterpolate4,
|
||||
ɵɵtextInterpolate5,
|
||||
ɵɵtextInterpolate6,
|
||||
ɵɵtextInterpolate7,
|
||||
ɵɵtextInterpolate8,
|
||||
ɵɵtextInterpolateV,
|
||||
} from './instructions/all';
|
||||
export {RenderFlags} from './interfaces/definition';
|
||||
export {CssSelectorList} from './interfaces/projection';
|
||||
|
||||
|
@ -36,6 +36,7 @@ export * from './element';
|
||||
export * from './element_container';
|
||||
export * from './embedded_view';
|
||||
export * from './get_current_view';
|
||||
export * from './interpolation';
|
||||
export * from './listener';
|
||||
export * from './namespace';
|
||||
export * from './next_context';
|
||||
@ -45,3 +46,4 @@ export * from './property_interpolation';
|
||||
export * from './select';
|
||||
export * from './styling';
|
||||
export * from './text';
|
||||
export * from './text_interpolation';
|
||||
|
@ -8,7 +8,7 @@
|
||||
import {SanitizerFn} from '../interfaces/sanitization';
|
||||
import {getSelectedIndex} from '../state';
|
||||
import {ɵɵelementAttribute} from './element';
|
||||
import {ɵɵinterpolation1, ɵɵinterpolation2, ɵɵinterpolation3, ɵɵinterpolation4, ɵɵinterpolation5, ɵɵinterpolation6, ɵɵinterpolation7, ɵɵinterpolation8, ɵɵinterpolationV} from './property_interpolation';
|
||||
import {ɵɵinterpolation1, ɵɵinterpolation2, ɵɵinterpolation3, ɵɵinterpolation4, ɵɵinterpolation5, ɵɵinterpolation6, ɵɵinterpolation7, ɵɵinterpolation8, ɵɵinterpolationV} from './interpolation';
|
||||
import {TsickleIssue1009} from './shared';
|
||||
|
||||
|
||||
|
289
packages/core/src/render3/instructions/interpolation.ts
Normal file
289
packages/core/src/render3/instructions/interpolation.ts
Normal file
@ -0,0 +1,289 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
import {assertEqual, assertLessThan} from '../../util/assert';
|
||||
import {bindingUpdated, bindingUpdated2, bindingUpdated3, bindingUpdated4} from '../bindings';
|
||||
import {BINDING_INDEX, TVIEW} from '../interfaces/view';
|
||||
import {getLView} from '../state';
|
||||
import {NO_CHANGE} from '../tokens';
|
||||
import {renderStringify} from '../util/misc_utils';
|
||||
|
||||
import {storeBindingMetadata} from './shared';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create interpolation bindings with a variable number of expressions.
|
||||
*
|
||||
* If there are 1 to 8 expressions `interpolation1()` to `interpolation8()` should be used instead.
|
||||
* Those are faster because there is no need to create an array of expressions and iterate over it.
|
||||
*
|
||||
* `values`:
|
||||
* - has static text at even indexes,
|
||||
* - has evaluated expressions at odd indexes.
|
||||
*
|
||||
* Returns the concatenated string when any of the arguments changes, `NO_CHANGE` otherwise.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolationV(values: any[]): string|NO_CHANGE {
|
||||
ngDevMode && assertLessThan(2, values.length, 'should have at least 3 values');
|
||||
ngDevMode && assertEqual(values.length % 2, 1, 'should have an odd number of values');
|
||||
let isBindingUpdated = false;
|
||||
const lView = getLView();
|
||||
const tData = lView[TVIEW].data;
|
||||
let bindingIndex = lView[BINDING_INDEX];
|
||||
|
||||
if (tData[bindingIndex] == null) {
|
||||
// 2 is the index of the first static interstitial value (ie. not prefix)
|
||||
for (let i = 2; i < values.length; i += 2) {
|
||||
tData[bindingIndex++] = values[i];
|
||||
}
|
||||
bindingIndex = lView[BINDING_INDEX];
|
||||
}
|
||||
|
||||
for (let i = 1; i < values.length; i += 2) {
|
||||
// Check if bindings (odd indexes) have changed
|
||||
isBindingUpdated = bindingUpdated(lView, bindingIndex++, values[i]) || isBindingUpdated;
|
||||
}
|
||||
lView[BINDING_INDEX] = bindingIndex;
|
||||
storeBindingMetadata(lView, values[0], values[values.length - 1]);
|
||||
|
||||
if (!isBindingUpdated) {
|
||||
return NO_CHANGE;
|
||||
}
|
||||
|
||||
// Build the updated content
|
||||
let content = values[0];
|
||||
for (let i = 1; i < values.length; i += 2) {
|
||||
content += renderStringify(values[i]) + values[i + 1];
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 1 expression.
|
||||
*
|
||||
* @param prefix static value used for concatenation only.
|
||||
* @param v0 value checked for change.
|
||||
* @param suffix static value used for concatenation only.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation1(prefix: string, v0: any, suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const different = bindingUpdated(lView, lView[BINDING_INDEX]++, v0);
|
||||
storeBindingMetadata(lView, prefix, suffix);
|
||||
return different ? prefix + renderStringify(v0) + suffix : NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 2 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation2(
|
||||
prefix: string, v0: any, i0: string, v1: any, suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
const different = bindingUpdated2(lView, bindingIndex, v0, v1);
|
||||
lView[BINDING_INDEX] += 2;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
lView[TVIEW].data[bindingIndex] = i0;
|
||||
}
|
||||
|
||||
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + suffix : NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 3 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation3(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, suffix: string): string|
|
||||
NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
const different = bindingUpdated3(lView, bindingIndex, v0, v1, v2);
|
||||
lView[BINDING_INDEX] += 3;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an interpolation binding with 4 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation4(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
lView[BINDING_INDEX] += 4;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 5 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation5(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
|
||||
lView[BINDING_INDEX] += 5;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
tData[bindingIndex + 3] = i3;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 6 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation6(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
different = bindingUpdated2(lView, bindingIndex + 4, v4, v5) || different;
|
||||
lView[BINDING_INDEX] += 6;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
tData[bindingIndex + 3] = i3;
|
||||
tData[bindingIndex + 4] = i4;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 7 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation7(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, suffix: string): string|
|
||||
NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
|
||||
lView[BINDING_INDEX] += 7;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
tData[bindingIndex + 3] = i3;
|
||||
tData[bindingIndex + 4] = i4;
|
||||
tData[bindingIndex + 5] = i5;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + i5 +
|
||||
renderStringify(v6) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 8 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation8(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, i6: string, v7: any,
|
||||
suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
|
||||
lView[BINDING_INDEX] += 8;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
tData[bindingIndex + 3] = i3;
|
||||
tData[bindingIndex + 4] = i4;
|
||||
tData[bindingIndex + 5] = i5;
|
||||
tData[bindingIndex + 6] = i6;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + i5 +
|
||||
renderStringify(v6) + i6 + renderStringify(v7) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
@ -5,293 +5,14 @@
|
||||
* 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
|
||||
*/
|
||||
import {assertEqual, assertLessThan} from '../../util/assert';
|
||||
import {bindingUpdated, bindingUpdated2, bindingUpdated3, bindingUpdated4} from '../bindings';
|
||||
import {SanitizerFn} from '../interfaces/sanitization';
|
||||
import {BINDING_INDEX, TVIEW} from '../interfaces/view';
|
||||
import {getLView, getSelectedIndex} from '../state';
|
||||
import {getSelectedIndex} from '../state';
|
||||
import {NO_CHANGE} from '../tokens';
|
||||
import {renderStringify} from '../util/misc_utils';
|
||||
|
||||
import {TsickleIssue1009, elementPropertyInternal, storeBindingMetadata} from './shared';
|
||||
import {ɵɵinterpolation1, ɵɵinterpolation2, ɵɵinterpolation3, ɵɵinterpolation4, ɵɵinterpolation5, ɵɵinterpolation6, ɵɵinterpolation7, ɵɵinterpolation8, ɵɵinterpolationV} from './interpolation';
|
||||
import {TsickleIssue1009, elementPropertyInternal} from './shared';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create interpolation bindings with a variable number of expressions.
|
||||
*
|
||||
* If there are 1 to 8 expressions `interpolation1()` to `interpolation8()` should be used instead.
|
||||
* Those are faster because there is no need to create an array of expressions and iterate over it.
|
||||
*
|
||||
* `values`:
|
||||
* - has static text at even indexes,
|
||||
* - has evaluated expressions at odd indexes.
|
||||
*
|
||||
* Returns the concatenated string when any of the arguments changes, `NO_CHANGE` otherwise.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolationV(values: any[]): string|NO_CHANGE {
|
||||
ngDevMode && assertLessThan(2, values.length, 'should have at least 3 values');
|
||||
ngDevMode && assertEqual(values.length % 2, 1, 'should have an odd number of values');
|
||||
let different = false;
|
||||
const lView = getLView();
|
||||
const tData = lView[TVIEW].data;
|
||||
let bindingIndex = lView[BINDING_INDEX];
|
||||
|
||||
if (tData[bindingIndex] == null) {
|
||||
// 2 is the index of the first static interstitial value (ie. not prefix)
|
||||
for (let i = 2; i < values.length; i += 2) {
|
||||
tData[bindingIndex++] = values[i];
|
||||
}
|
||||
bindingIndex = lView[BINDING_INDEX];
|
||||
}
|
||||
|
||||
for (let i = 1; i < values.length; i += 2) {
|
||||
// Check if bindings (odd indexes) have changed
|
||||
bindingUpdated(lView, bindingIndex++, values[i]) && (different = true);
|
||||
}
|
||||
lView[BINDING_INDEX] = bindingIndex;
|
||||
storeBindingMetadata(lView, values[0], values[values.length - 1]);
|
||||
|
||||
if (!different) {
|
||||
return NO_CHANGE;
|
||||
}
|
||||
|
||||
// Build the updated content
|
||||
let content = values[0];
|
||||
for (let i = 1; i < values.length; i += 2) {
|
||||
content += renderStringify(values[i]) + values[i + 1];
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 1 expression.
|
||||
*
|
||||
* @param prefix static value used for concatenation only.
|
||||
* @param v0 value checked for change.
|
||||
* @param suffix static value used for concatenation only.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation1(prefix: string, v0: any, suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const different = bindingUpdated(lView, lView[BINDING_INDEX]++, v0);
|
||||
storeBindingMetadata(lView, prefix, suffix);
|
||||
return different ? prefix + renderStringify(v0) + suffix : NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 2 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation2(
|
||||
prefix: string, v0: any, i0: string, v1: any, suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
const different = bindingUpdated2(lView, bindingIndex, v0, v1);
|
||||
lView[BINDING_INDEX] += 2;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
lView[TVIEW].data[bindingIndex] = i0;
|
||||
}
|
||||
|
||||
return different ? prefix + renderStringify(v0) + i0 + renderStringify(v1) + suffix : NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 3 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation3(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, suffix: string): string|
|
||||
NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
const different = bindingUpdated3(lView, bindingIndex, v0, v1, v2);
|
||||
lView[BINDING_INDEX] += 3;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an interpolation binding with 4 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation4(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
const different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
lView[BINDING_INDEX] += 4;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 5 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation5(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
different = bindingUpdated(lView, bindingIndex + 4, v4) || different;
|
||||
lView[BINDING_INDEX] += 5;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
tData[bindingIndex + 3] = i3;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 6 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation6(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
different = bindingUpdated2(lView, bindingIndex + 4, v4, v5) || different;
|
||||
lView[BINDING_INDEX] += 6;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
tData[bindingIndex + 3] = i3;
|
||||
tData[bindingIndex + 4] = i4;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 7 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation7(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, suffix: string): string|
|
||||
NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
different = bindingUpdated3(lView, bindingIndex + 4, v4, v5, v6) || different;
|
||||
lView[BINDING_INDEX] += 7;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
tData[bindingIndex + 3] = i3;
|
||||
tData[bindingIndex + 4] = i4;
|
||||
tData[bindingIndex + 5] = i5;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + i5 +
|
||||
renderStringify(v6) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an interpolation binding with 8 expressions.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵinterpolation8(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, i6: string, v7: any,
|
||||
suffix: string): string|NO_CHANGE {
|
||||
const lView = getLView();
|
||||
const bindingIndex = lView[BINDING_INDEX];
|
||||
let different = bindingUpdated4(lView, bindingIndex, v0, v1, v2, v3);
|
||||
different = bindingUpdated4(lView, bindingIndex + 4, v4, v5, v6, v7) || different;
|
||||
lView[BINDING_INDEX] += 8;
|
||||
|
||||
// Only set static strings the first time (data will be null subsequent runs).
|
||||
const data = storeBindingMetadata(lView, prefix, suffix);
|
||||
if (data) {
|
||||
const tData = lView[TVIEW].data;
|
||||
tData[bindingIndex] = i0;
|
||||
tData[bindingIndex + 1] = i1;
|
||||
tData[bindingIndex + 2] = i2;
|
||||
tData[bindingIndex + 3] = i3;
|
||||
tData[bindingIndex + 4] = i4;
|
||||
tData[bindingIndex + 5] = i5;
|
||||
tData[bindingIndex + 6] = i6;
|
||||
}
|
||||
|
||||
return different ?
|
||||
prefix + renderStringify(v0) + i0 + renderStringify(v1) + i1 + renderStringify(v2) + i2 +
|
||||
renderStringify(v3) + i3 + renderStringify(v4) + i4 + renderStringify(v5) + i5 +
|
||||
renderStringify(v6) + i6 + renderStringify(v7) + suffix :
|
||||
NO_CHANGE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
/// NEW INSTRUCTIONS
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
*
|
||||
* Update an interpolated property on an element with a lone bound value
|
||||
|
298
packages/core/src/render3/instructions/text_interpolation.ts
Normal file
298
packages/core/src/render3/instructions/text_interpolation.ts
Normal file
@ -0,0 +1,298 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
import {getSelectedIndex} from '../state';
|
||||
|
||||
import {ɵɵinterpolation1, ɵɵinterpolation2, ɵɵinterpolation3, ɵɵinterpolation4, ɵɵinterpolation5, ɵɵinterpolation6, ɵɵinterpolation7, ɵɵinterpolation8, ɵɵinterpolationV} from './interpolation';
|
||||
import {TsickleIssue1009} from './shared';
|
||||
import {ɵɵtextBinding} from './text';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with a lone bound value
|
||||
*
|
||||
* Used when a text node has 1 interpolated value in it, an no additional text
|
||||
* surrounds that interpolated value:
|
||||
*
|
||||
* ```html
|
||||
* <div>{{v0}}</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate(v0);
|
||||
* ```
|
||||
* @returns itself, so that it may be chained.
|
||||
* @see textInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate(v0: any): TsickleIssue1009 {
|
||||
ɵɵtextInterpolate1('', v0, '');
|
||||
return ɵɵtextInterpolate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with single bound value surrounded by other text.
|
||||
*
|
||||
* Used when a text node has 1 interpolated value in it:
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate1('prefix', v0, 'suffix');
|
||||
* ```
|
||||
* @returns itself, so that it may be chained.
|
||||
* @see textInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate1(prefix: string, v0: any, suffix: string): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
ɵɵtextBinding(index, ɵɵinterpolation1(prefix, v0, suffix));
|
||||
return ɵɵtextInterpolate1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with 2 bound values surrounded by other text.
|
||||
*
|
||||
* Used when a text node has 2 interpolated values in it:
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}-{{v1}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate2('prefix', v0, '-', v1, 'suffix');
|
||||
* ```
|
||||
* @returns itself, so that it may be chained.
|
||||
* @see textInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate2(
|
||||
prefix: string, v0: any, i0: string, v1: any, suffix: string): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
ɵɵtextBinding(index, ɵɵinterpolation2(prefix, v0, i0, v1, suffix));
|
||||
return ɵɵtextInterpolate2;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with 3 bound values surrounded by other text.
|
||||
*
|
||||
* Used when a text node has 3 interpolated values in it:
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}-{{v1}}-{{v2}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate3(
|
||||
* 'prefix', v0, '-', v1, '-', v2, 'suffix');
|
||||
* ```
|
||||
* @returns itself, so that it may be chained.
|
||||
* @see textInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate3(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any,
|
||||
suffix: string): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
ɵɵtextBinding(index, ɵɵinterpolation3(prefix, v0, i0, v1, i1, v2, suffix));
|
||||
return ɵɵtextInterpolate3;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with 4 bound values surrounded by other text.
|
||||
*
|
||||
* Used when a text node has 4 interpolated values in it:
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate4(
|
||||
* 'prefix', v0, '-', v1, '-', v2, '-', v3, 'suffix');
|
||||
* ```
|
||||
* @returns itself, so that it may be chained.
|
||||
* @see ɵɵtextInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate4(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
suffix: string): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
ɵɵtextBinding(index, ɵɵinterpolation4(prefix, v0, i0, v1, i1, v2, i2, v3, suffix));
|
||||
return ɵɵtextInterpolate4;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with 5 bound values surrounded by other text.
|
||||
*
|
||||
* Used when a text node has 5 interpolated values in it:
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate5(
|
||||
* 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, 'suffix');
|
||||
* ```
|
||||
* @returns itself, so that it may be chained.
|
||||
* @see textInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate5(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, suffix: string): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
ɵɵtextBinding(index, ɵɵinterpolation5(prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, suffix));
|
||||
return ɵɵtextInterpolate5;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with 6 bound values surrounded by other text.
|
||||
*
|
||||
* Used when a text node has 6 interpolated values in it:
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate6(
|
||||
* 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, 'suffix');
|
||||
* ```
|
||||
*
|
||||
* @param i4 Static value used for concatenation only.
|
||||
* @param v5 Value checked for change. @returns itself, so that it may be chained.
|
||||
* @see textInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate6(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, suffix: string): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
ɵɵtextBinding(
|
||||
index, ɵɵinterpolation6(prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, suffix));
|
||||
return ɵɵtextInterpolate6;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with 7 bound values surrounded by other text.
|
||||
*
|
||||
* Used when a text node has 7 interpolated values in it:
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate7(
|
||||
* 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, 'suffix');
|
||||
* ```
|
||||
* @returns itself, so that it may be chained.
|
||||
* @see textInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate7(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, i5: string, v6: any,
|
||||
suffix: string): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
ɵɵtextBinding(
|
||||
index, ɵɵinterpolation7(prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, suffix));
|
||||
return ɵɵtextInterpolate7;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Update text content with 8 bound values surrounded by other text.
|
||||
*
|
||||
* Used when a text node has 8 interpolated values in it:
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}-{{v7}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolate8(
|
||||
* 'prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, '-', v7, 'suffix');
|
||||
* ```
|
||||
* @returns itself, so that it may be chained.
|
||||
* @see textInterpolateV
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolate8(
|
||||
prefix: string, v0: any, i0: string, v1: any, i1: string, v2: any, i2: string, v3: any,
|
||||
i3: string, v4: any, i4: string, v5: any, i5: string, v6: any, i6: string, v7: any,
|
||||
suffix: string): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
ɵɵtextBinding(
|
||||
index,
|
||||
ɵɵinterpolation8(prefix, v0, i0, v1, i1, v2, i2, v3, i3, v4, i4, v5, i5, v6, i6, v7, suffix));
|
||||
return ɵɵtextInterpolate8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update text content with 9 or more bound values other surrounded by text.
|
||||
*
|
||||
* Used when the number of interpolated values exceeds 8.
|
||||
*
|
||||
* ```html
|
||||
* <div>prefix{{v0}}-{{v1}}-{{v2}}-{{v3}}-{{v4}}-{{v5}}-{{v6}}-{{v7}}-{{v8}}-{{v9}}suffix</div>
|
||||
* ```
|
||||
*
|
||||
* Its compiled representation is:
|
||||
*
|
||||
* ```ts
|
||||
* ɵɵtextInterpolateV(
|
||||
* ['prefix', v0, '-', v1, '-', v2, '-', v3, '-', v4, '-', v5, '-', v6, '-', v7, '-', v9,
|
||||
* 'suffix']);
|
||||
* ```
|
||||
*.
|
||||
* @param values The a collection of values and the strings in between those values, beginning with
|
||||
* a string prefix and ending with a string suffix.
|
||||
* (e.g. `['prefix', value0, '-', value1, '-', value2, ..., value99, 'suffix']`)
|
||||
*
|
||||
* @returns itself, so that it may be chained.
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtextInterpolateV(values: any[]): TsickleIssue1009 {
|
||||
const index = getSelectedIndex();
|
||||
|
||||
ɵɵtextBinding(index, ɵɵinterpolationV(values));
|
||||
return ɵɵtextInterpolateV;
|
||||
}
|
@ -127,6 +127,16 @@ export const angularCoreEnv: {[name: string]: Function} =
|
||||
'ɵɵtemplate': r3.ɵɵtemplate,
|
||||
'ɵɵtext': r3.ɵɵtext,
|
||||
'ɵɵtextBinding': r3.ɵɵtextBinding,
|
||||
'ɵɵtextInterpolate': r3.ɵɵtextInterpolate,
|
||||
'ɵɵtextInterpolate1': r3.ɵɵtextInterpolate1,
|
||||
'ɵɵtextInterpolate2': r3.ɵɵtextInterpolate2,
|
||||
'ɵɵtextInterpolate3': r3.ɵɵtextInterpolate3,
|
||||
'ɵɵtextInterpolate4': r3.ɵɵtextInterpolate4,
|
||||
'ɵɵtextInterpolate5': r3.ɵɵtextInterpolate5,
|
||||
'ɵɵtextInterpolate6': r3.ɵɵtextInterpolate6,
|
||||
'ɵɵtextInterpolate7': r3.ɵɵtextInterpolate7,
|
||||
'ɵɵtextInterpolate8': r3.ɵɵtextInterpolate8,
|
||||
'ɵɵtextInterpolateV': r3.ɵɵtextInterpolateV,
|
||||
'ɵɵembeddedViewStart': r3.ɵɵembeddedViewStart,
|
||||
'ɵɵembeddedViewEnd': r3.ɵɵembeddedViewEnd,
|
||||
'ɵɵi18n': r3.ɵɵi18n,
|
||||
|
Reference in New Issue
Block a user