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:
Ben Lesh
2019-05-15 19:20:02 -07:00
committed by Jason Aden
parent 10f48278c2
commit 38d7acee4d
10 changed files with 657 additions and 634 deletions

View File

@ -8,6 +8,7 @@
// clang-format off
export {
ɵɵattribute,
ɵɵdefineBase,
ɵɵdefineComponent,
ɵɵdefineDirective,

View File

@ -21,7 +21,9 @@ export {
markDirty,
store,
tick,
ɵɵallocHostVars,
ɵɵattribute,
ɵɵbind,
ɵɵclassMap,
ɵɵclassProp,

View File

@ -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';

View 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);
}

View File

@ -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.

View File

@ -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,