refactor(ivy): add new ɵɵattribute instruction (#30503)
- adds the ɵɵattribute instruction - adds compilation handling for Δattribute instruction - updates tests PR Close #30503
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
|
||||
// clang-format off
|
||||
export {
|
||||
ɵɵattribute,
|
||||
ɵɵdefineBase,
|
||||
ɵɵdefineComponent,
|
||||
ɵɵdefineDirective,
|
||||
|
@ -21,7 +21,9 @@ export {
|
||||
markDirty,
|
||||
store,
|
||||
tick,
|
||||
|
||||
ɵɵallocHostVars,
|
||||
ɵɵattribute,
|
||||
ɵɵbind,
|
||||
ɵɵclassMap,
|
||||
ɵɵclassProp,
|
||||
|
@ -26,6 +26,7 @@
|
||||
* Jira Issue = FW-1184
|
||||
*/
|
||||
export * from './alloc_host_vars';
|
||||
export * from './attribute';
|
||||
export * from './change_detection';
|
||||
export * from './container';
|
||||
export * from './storage';
|
||||
|
31
packages/core/src/render3/instructions/attribute.ts
Normal file
31
packages/core/src/render3/instructions/attribute.ts
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @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 {SanitizerFn} from '../interfaces/sanitization';
|
||||
import {getSelectedIndex} from '../state';
|
||||
|
||||
import {ΔelementAttribute} from './element';
|
||||
import {Δbind} from './property';
|
||||
|
||||
/**
|
||||
* Updates the value of or removes a bound attribute on an Element.
|
||||
*
|
||||
* Used in the case of `[attr.title]="value"`
|
||||
*
|
||||
* @param name name The name of the attribute.
|
||||
* @param value value The attribute is removed when value is `null` or `undefined`.
|
||||
* Otherwise the attribute value is set to the stringified value.
|
||||
* @param sanitizer An optional function used to sanitize the value.
|
||||
* @param namespace Optional namespace to use when setting the attribute.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function Δattribute(
|
||||
name: string, value: any, sanitizer?: SanitizerFn | null, namespace?: string) {
|
||||
const index = getSelectedIndex();
|
||||
return ΔelementAttribute(index, name, Δbind(value), sanitizer, namespace);
|
||||
}
|
@ -198,7 +198,7 @@ export function ɵɵelement(
|
||||
|
||||
|
||||
/**
|
||||
* Updates the value of removes an attribute on an Element.
|
||||
* Updates the value or removes an attribute on an Element.
|
||||
*
|
||||
* @param number index The index of the element in the data array
|
||||
* @param name name The name of the attribute.
|
||||
|
@ -20,6 +20,7 @@ import * as r3 from '../index';
|
||||
*/
|
||||
export const angularCoreEnv: {[name: string]: Function} =
|
||||
(() => ({
|
||||
'ɵɵattribute': r3.ɵɵattribute,
|
||||
'ɵɵdefineBase': r3.ɵɵdefineBase,
|
||||
'ɵɵdefineComponent': r3.ɵɵdefineComponent,
|
||||
'ɵɵdefineDirective': r3.ɵɵdefineDirective,
|
||||
|
Reference in New Issue
Block a user