-
Notifications
You must be signed in to change notification settings - Fork 0
✨ start upgrading to angular 20 #3
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d2a6f60
df250f0
5408d23
2e62f7c
c8f0549
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| <span *ngFor="let holder of placeholders; index as i" | ||
| [class.code-hidden]="isCodeHidden"> | ||
| <input #input | ||
| (click)="onClick($event)" | ||
| (paste)="onPaste($event, i)" | ||
| (input)="onInput($event, i)" | ||
| (keydown)="onKeydown($event, i)" | ||
| [type]="inputType" | ||
| [disabled]="disabled" | ||
| [attr.inputmode]="inputMode" | ||
| [attr.autocapitalize]="autocapitalize" | ||
| autocomplete="one-time-code"/> | ||
| </span> | ||
| @for (holder of placeholders; track holder; let i = $index) { | ||
| <span | ||
| [class.code-hidden]="isCodeHidden"> | ||
| <input #input | ||
| (click)="onClick($event)" | ||
| (paste)="onPaste($event, i)" | ||
| (input)="onInput($event, i)" | ||
| (keydown)="onKeydown($event, i)" | ||
| [type]="inputType" | ||
| [disabled]="disabled" | ||
| [attr.inputmode]="inputMode" | ||
| [attr.autocapitalize]="autocapitalize" | ||
| autocomplete="one-time-code"/> | ||
| </span> | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,17 +4,17 @@ import { | |
| Component, | ||
| ElementRef, | ||
| EventEmitter, | ||
| Inject, | ||
| inject, | ||
| Input, | ||
| OnChanges, | ||
| OnDestroy, | ||
| OnInit, | ||
| Optional, | ||
| Output, | ||
| QueryList, | ||
| SimpleChanges, | ||
| ViewChildren | ||
| } from '@angular/core'; | ||
| import { CommonModule } from '@angular/common'; | ||
| import { | ||
| CodeInputComponentConfig, | ||
| CodeInputComponentConfigToken, | ||
|
|
@@ -28,9 +28,10 @@ enum InputState { | |
| } | ||
|
|
||
| @Component({ | ||
| selector: 'code-input', | ||
| templateUrl: 'code-input.component.html', | ||
| styleUrls: ['./code-input.component.scss'] | ||
| imports: [CommonModule], | ||
| selector: 'code-input', | ||
| templateUrl: 'code-input.component.html', | ||
| styleUrls: ['./code-input.component.scss'] | ||
| }) | ||
| export class CodeInputComponent implements AfterViewInit, OnInit, OnChanges, OnDestroy, AfterViewChecked, CodeInputComponentConfig { | ||
|
|
||
|
|
@@ -65,16 +66,19 @@ export class CodeInputComponent implements AfterViewInit, OnInit, OnChanges, OnD | |
| isInitialFocusFieldEnabled: false | ||
| }; | ||
|
|
||
| constructor(@Optional() @Inject(CodeInputComponentConfigToken) config?: CodeInputComponentConfig) { | ||
| // Modern dependency injection using inject() function | ||
| private readonly config = inject(CodeInputComponentConfigToken, { optional: true }); | ||
|
|
||
| constructor() { | ||
| Object.assign(this, defaultComponentConfig); | ||
|
|
||
| if (!config) { | ||
| if (!this.config) { | ||
| return; | ||
| } | ||
|
|
||
| // filtering for only valid config props | ||
| for (const prop in config) { | ||
| if (!config.hasOwnProperty(prop)) { | ||
| for (const prop in this.config) { | ||
| if (!this.config.hasOwnProperty(prop)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Modernize to Object.hasOwn() for better JavaScript practices The static analysis correctly identifies that Apply this diff to use the modern approach: - if (!this.config.hasOwnProperty(prop)) {
+ if (!Object.hasOwn(this.config, prop)) {🧰 Tools🪛 Biome (1.9.4)[error] 81-81: Do not access Object.prototype method 'hasOwnProperty' from target object. It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty(). (lint/suspicious/noPrototypeBuiltins) 🤖 Prompt for AI Agents |
||
| continue; | ||
| } | ||
|
|
||
|
|
@@ -83,7 +87,7 @@ export class CodeInputComponent implements AfterViewInit, OnInit, OnChanges, OnD | |
| } | ||
|
|
||
| // @ts-ignore | ||
| this[prop] = config[prop]; | ||
| this[prop] = this.config[prop]; | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use a stable key in
trackto avoid unnecessary DOM churntrack holderre-evaluates by object identity.If
placeholdersis rebuilt on every change-detection cycle (e.g.Array(n).fill('')), all inputs will be re-created. Prefer a stable scalar such as the loop index:This keeps focus/selection intact and improves performance.
📝 Committable suggestion
🤖 Prompt for AI Agents