Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor(forms): remove unused and duplicate code#66186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
leonsenft wants to merge2 commits intoangular:mainfromleonsenft:sf-reuse-property
Closed
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
refactor(forms): reuseɵɵproperty to reduce duplicate code
Reuse `ɵɵproperty` to implement `ɵɵcontrol` instead of duplicating itsimplementation.
  • Loading branch information
@leonsenft
leonsenft committedDec 18, 2025
commit2c20f6fbe2fcb161cf24116f6f22cae75de288b6
32 changes: 6 additions & 26 deletionspackages/core/src/render3/instructions/control.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,6 @@ import {RuntimeError, RuntimeErrorCode} from '../../errors';
import {performanceMarkFeature} from '../../util/performance';
import {getClosureSafeProperty} from '../../util/property';
import {assertFirstCreatePass} from '../assert';
import {bindingUpdated} from '../bindings';
import {ɵCONTROL, ɵControl, ɵFieldState} from '../interfaces/control';
import {DirectiveDef} from '../interfaces/definition';
import {InputFlags} from '../interfaces/input_flags';
Expand All@@ -34,7 +33,7 @@ import {debugStringifyTypeForError} from '../util/stringify_utils';
import {getNativeByTNode, storeCleanupWithContext} from '../util/view_utils';
import {listenToOutput} from '../view/directive_outputs';
import {listenToDomEvent, wrapListener} from '../view/listeners';
import {setPropertyAndInputs, storePropertyBindingMetadata} from './shared';
import {ɵɵproperty} from './property';
import {writeToDirectiveInput} from './write_to_directive_input';

/**
Expand DownExpand Up@@ -87,21 +86,14 @@ export function ɵɵcontrolCreate(): void {
* @codeGenApi
*/
export function ɵɵcontrol<T>(value: T, sanitizer?: SanitizerFn | null): void {
const lView = getLView();
const tNode = getSelectedTNode();
const bindingIndex = nextBindingIndex();

if (bindingUpdated(lView, bindingIndex, value)) {
const tView = getTView();
setPropertyAndInputs(tNode, lView, 'field', value, lView[RENDERER], sanitizer);
ngDevMode && storePropertyBindingMetadata(tView.data, tNode, 'field', bindingIndex);
}

updateControl(lView, tNode);
ɵɵproperty('field', value, sanitizer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

At least in the past we had this rule about not having instructions calling other instructions directly, it's why we have thesetPropertyAndInputs utility function which is basically the implementation ofproperty without the change detection parts.

ɵcontrolUpdate();
}

/**
* Calls {@link updateControl} with the current `LView` and selected `TNode`.
* Updates the form control properties of a `field` bound form control.
*
* Does nothing if the current node is not a `field` bound form control.
*
* NOTE: This instruction exists solely to accommodate tree-shakeable, dynamic control bindings.
* It's intended to be referenced exclusively by the Signal Forms `Field` directive and should not
Expand All@@ -110,18 +102,6 @@ export function ɵɵcontrol<T>(value: T, sanitizer?: SanitizerFn | null): void {
export function ɵcontrolUpdate(): void {
const lView = getLView();
const tNode = getSelectedTNode();
updateControl(lView, tNode);
}

/**
* Updates the form control properties of a `field` bound form control.
*
* Does nothing if the current node is not a `field` bound form control.
*
* @param lView The `LView` that contains the control.
* @param tNode The `TNode` of the control.
*/
function updateControl<T>(lView: LView, tNode: TNode): void {
const control = getControlDirective(tNode, lView);
if (control) {
updateControlClasses(lView, tNode, control);
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp