* Search the `TAttributes` to see if it contains `cssClassToMatch` (case insensitive) * * @param tNode static data of the node to match * @param attrs `TAttributes` to search through. * @param cssClassToMatch class to match (lowercase) * @param isProjectionMode Whether or not class matching sho
( tNode: TNode, attrs: TAttributes, cssClassToMatch: string, isProjectionMode: boolean, )
| 28 | * addition to the `AttributeMarker.Classes`. |
| 29 | */ |
| 30 | function isCssClassMatching( |
| 31 | tNode: TNode, |
| 32 | attrs: TAttributes, |
| 33 | cssClassToMatch: string, |
| 34 | isProjectionMode: boolean, |
| 35 | ): boolean { |
| 36 | ngDevMode && |
| 37 | assertEqual( |
| 38 | cssClassToMatch, |
| 39 | cssClassToMatch.toLowerCase(), |
| 40 | 'Class name expected to be lowercase.', |
| 41 | ); |
| 42 | let i = 0; |
| 43 | if (isProjectionMode) { |
| 44 | for (; i < attrs.length && typeof attrs[i] === 'string'; i += 2) { |
| 45 | // Search for an implicit `class` attribute and check if its value matches `cssClassToMatch`. |
| 46 | if ( |
| 47 | attrs[i] === 'class' && |
| 48 | classIndexOf((attrs[i + 1] as string).toLowerCase(), cssClassToMatch, 0) !== -1 |
| 49 | ) { |
| 50 | return true; |
| 51 | } |
| 52 | } |
| 53 | } else if (isInlineTemplate(tNode)) { |
| 54 | // Matching directives (i.e. when not matching for projection mode) should not consider the |
| 55 | // class bindings that are present on inline templates, as those class bindings only target |
| 56 | // the root node of the template, not the template itself. |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | // Resume the search for classes after the `Classes` marker. |
| 61 | i = attrs.indexOf(AttributeMarker.Classes, i); |
| 62 | if (i > -1) { |
| 63 | // We found the classes section. Start searching for the class. |
| 64 | let item: TAttributes[number]; |
| 65 | while (++i < attrs.length && typeof (item = attrs[i]) === 'string') { |
| 66 | if (item.toLowerCase() === cssClassToMatch) { |
| 67 | return true; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | return false; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Checks whether the `tNode` represents an inline template (e.g. `*ngFor`). |
no test coverage detected
searching dependent graphs…