Skip to content

Commit

Permalink
fix(angular): avoid forEach in classList
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Nov 19, 2018
1 parent 723296e commit 359bdcf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions angular/src/directives/control-value-accessors/value-accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ function setIonicClasses(element: ElementRef) {
'ion-pristine'
);

classList.forEach((cls: string) => {
if (cls.startsWith('ng-')) {
classList.add(`ion-${cls.substr(3)}`);
for (let i = 0; i < classList.length; i++) {
const item = classList.item(i);
if (item && startsWith(item, 'ng-')) {
classList.add(`ion-${item.substr(3)}`);
}
});
}
});
}

function startsWith(input: string, search: string): boolean {
return input.substr(0, search.length) === search;
}

0 comments on commit 359bdcf

Please sign in to comment.