The :host-context() selector lets a shadow component change its styling when its surrounding context matches a selector. That is useful when one component needs different layouts or controls in different parts of an application. section 10.1
A Workout Creator example uses the selector to distinguish an exercise in the library from one in the workout plan:
A portable workaround
Because browser support is unreliable, add context directly to the host: use class="library" for library exercises and class="plan" for plan exercises. Replace the contextual selectors with :host(.library) and :host(.plan), as in Listing 10.8.
The selector is not formally deprecated, but Chrome is the only browser identified as supporting it. Safari rejected support as an anti-pattern, Firefox raised performance concerns, and its future in the Shadow DOM specification was considered uncertain. Angular can provide similar behavior at the framework level. section 10.1
Compare the library and plan presentations of the same exercise component. section 10.1
