( className: string, classToSearch: string, startingIndex: number, )
| 20 | * @returns an index of the located class (or -1 if not found) |
| 21 | */ |
| 22 | export function classIndexOf( |
| 23 | className: string, |
| 24 | classToSearch: string, |
| 25 | startingIndex: number, |
| 26 | ): number { |
| 27 | ngDevMode && assertNotEqual(classToSearch, '', 'can not look for "" string.'); |
| 28 | let end = className.length; |
| 29 | while (true) { |
| 30 | const foundIndex = className.indexOf(classToSearch, startingIndex); |
| 31 | if (foundIndex === -1) return foundIndex; |
| 32 | if (foundIndex === 0 || className.charCodeAt(foundIndex - 1) <= CharCode.SPACE) { |
| 33 | // Ensure that it has leading whitespace |
| 34 | const length = classToSearch.length; |
| 35 | if ( |
| 36 | foundIndex + length === end || |
| 37 | className.charCodeAt(foundIndex + length) <= CharCode.SPACE |
| 38 | ) { |
| 39 | // Ensure that it has trailing whitespace |
| 40 | return foundIndex; |
| 41 | } |
| 42 | } |
| 43 | // False positive, keep searching from where we left off. |
| 44 | startingIndex = foundIndex + 1; |
| 45 | } |
| 46 | } |
no test coverage detected
searching dependent graphs…