Skip to content

Commit ab18e51

Browse files
committed
MOBILE-4616 database: Fix specificity of custom CSS rules
1 parent 258650a commit ab18e51

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/core/features/compile/components/compile-html/compile-html.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,15 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
202202
return;
203203
}
204204

205-
this.componentStyles = CoreDom.prefixCSS(this.cssCode, ':host ::ng-deep', ':host');
205+
// Prefix all CSS rules with the host attribute and [compiled-component-id].
206+
// We need [compiled-component-id] to increase the specificity of the prefix to 0,2,0.
207+
// This way rules added by the parent component using a class has the same base
208+
// specificity and do not override the added rules.
209+
this.componentStyles = CoreDom.prefixCSS(
210+
this.cssCode,
211+
':host([compiled-component-id]) ::ng-deep',
212+
':host([compiled-component-id])',
213+
);
206214
}
207215

208216
/**

0 commit comments

Comments
 (0)