Skip to content

Commit 359bdcf

Browse files
committed
fix(angular): avoid forEach in classList
1 parent 723296e commit 359bdcf

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

angular/src/directives/control-value-accessors/value-accessor.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,15 @@ function setIonicClasses(element: ElementRef) {
5454
'ion-pristine'
5555
);
5656

57-
classList.forEach((cls: string) => {
58-
if (cls.startsWith('ng-')) {
59-
classList.add(`ion-${cls.substr(3)}`);
57+
for (let i = 0; i < classList.length; i++) {
58+
const item = classList.item(i);
59+
if (item && startsWith(item, 'ng-')) {
60+
classList.add(`ion-${item.substr(3)}`);
6061
}
61-
});
62+
}
6263
});
6364
}
65+
66+
function startsWith(input: string, search: string): boolean {
67+
return input.substr(0, search.length) === search;
68+
}

0 commit comments

Comments
 (0)