* Marks `TStyleValue`s as duplicates if another style binding in the list has the same * `TStyleValue`. * * NOTE: this function is intended to be called twice once with `isPrevDir` set to `true` and once * with it set to `false` to search both the previous as well as next items in the list. *
( tData: TData, tStylingKey: TStylingKeyPrimitive, index: number, isPrevDir: boolean, )
| 385 | * - `false` for next (higher priority). |
| 386 | */ |
| 387 | function markDuplicates( |
| 388 | tData: TData, |
| 389 | tStylingKey: TStylingKeyPrimitive, |
| 390 | index: number, |
| 391 | isPrevDir: boolean, |
| 392 | ) { |
| 393 | const tStylingAtIndex = tData[index + 1] as TStylingRange; |
| 394 | const isMap = tStylingKey === null; |
| 395 | let cursor = isPrevDir |
| 396 | ? getTStylingRangePrev(tStylingAtIndex) |
| 397 | : getTStylingRangeNext(tStylingAtIndex); |
| 398 | let foundDuplicate = false; |
| 399 | // We keep iterating as long as we have a cursor |
| 400 | // AND either: |
| 401 | // - we found what we are looking for, OR |
| 402 | // - we are a map in which case we have to continue searching even after we find what we were |
| 403 | // looking for since we are a wild card and everything needs to be flipped to duplicate. |
| 404 | while (cursor !== 0 && (foundDuplicate === false || isMap)) { |
| 405 | ngDevMode && assertIndexInRange(tData, cursor); |
| 406 | const tStylingValueAtCursor = tData[cursor] as TStylingKey; |
| 407 | const tStyleRangeAtCursor = tData[cursor + 1] as TStylingRange; |
| 408 | if (isStylingMatch(tStylingValueAtCursor, tStylingKey)) { |
| 409 | foundDuplicate = true; |
| 410 | tData[cursor + 1] = isPrevDir |
| 411 | ? setTStylingRangeNextDuplicate(tStyleRangeAtCursor) |
| 412 | : setTStylingRangePrevDuplicate(tStyleRangeAtCursor); |
| 413 | } |
| 414 | cursor = isPrevDir |
| 415 | ? getTStylingRangePrev(tStyleRangeAtCursor) |
| 416 | : getTStylingRangeNext(tStyleRangeAtCursor); |
| 417 | } |
| 418 | if (foundDuplicate) { |
| 419 | // if we found a duplicate, than mark ourselves. |
| 420 | tData[index + 1] = isPrevDir |
| 421 | ? setTStylingRangePrevDuplicate(tStylingAtIndex) |
| 422 | : setTStylingRangeNextDuplicate(tStylingAtIndex); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * Determines if two `TStylingKey`s are a match. |
no test coverage detected
searching dependent graphs…