(cssText: string, selector: string, hostSelector: string = '')
| 173 | * The hostSelector is the attribute added to the host itself. |
| 174 | */ |
| 175 | shimCssText(cssText: string, selector: string, hostSelector: string = ''): string { |
| 176 | // **NOTE**: Do not strip comments as this will cause component sourcemaps to break |
| 177 | // due to shift in lines. |
| 178 | |
| 179 | // Collect comments and replace them with a placeholder, this is done to avoid complicating |
| 180 | // the rule parsing RegExp and keep it safer. |
| 181 | const comments: string[] = []; |
| 182 | cssText = cssText.replace(_commentRe, (m) => { |
| 183 | if (m.match(_commentWithHashRe)) { |
| 184 | comments.push(m); |
| 185 | } else { |
| 186 | // Replace non hash comments with empty lines. |
| 187 | // This is done so that we do not leak any sensitive data in comments. |
| 188 | const newLinesMatches = m.match(_newLinesRe); |
| 189 | comments.push(newLinesMatches?.join('') ?? ''); |
| 190 | } |
| 191 | |
| 192 | return COMMENT_PLACEHOLDER; |
| 193 | }); |
| 194 | |
| 195 | const scopedCssText = this._scopeCssText(cssText, selector, hostSelector); |
| 196 | // Add back comments at the original position. |
| 197 | let commentIdx = 0; |
| 198 | return scopedCssText.replace(_commentWithHashPlaceHolderRe, () => comments[commentIdx++]); |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Process styles to add scope to keyframes. |
no test coverage detected