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