/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/core/src/render3/instructions/attribute.ts
42 строки
1 KB
Kristiyan Kostadinov
refactor(core): handle NO_CHANGE in bindingUpdated (#61557)
21 май 2025, 18:13
21 май 2025, 18:13
1650a85
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC 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.dev/license */ import {bindingUpdated} from '../bindings'; import {SanitizerFn} from '../interfaces/sanitization'; import {getLView, getSelectedTNode, getTView, nextBindingIndex} from '../state'; import {elementAttributeInternal, storePropertyBindingMetadata} from './shared'; /** * 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, ): typeof ɵɵattribute { const lView = getLView(); const bindingIndex = nextBindingIndex(); if (bindingUpdated(lView, bindingIndex, value)) { const tView = getTView(); const tNode = getSelectedTNode(); elementAttributeInternal(tNode, lView, name, value, sanitizer, namespace); ngDevMode && storePropertyBindingMetadata(tView.data, tNode, 'attr.' + name, bindingIndex); } return ɵɵattribute; }