Skip to content

Commit

Permalink
fix(styles): use polymer *stylesFromModule* to retrieve styles from d…
Browse files Browse the repository at this point in the history
…om-modules #90
  • Loading branch information
akaegi authored and asyncLiz committed Jun 19, 2019
1 parent 3b278cd commit f585ccd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Binary file added codebakery-origami-3.1.0.tgz
Binary file not shown.
3 changes: 3 additions & 0 deletions styles/src/modules/import-style-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let CACHED_STYLE_MODULES = new Map<string, string>();
* `<style>` content for the module. Ensure that the module is imported and
* added to the DOM before calling `importStyleModule()`.
*
* @deprecated importStyleModule will be removed in the next major release.
* @param styleModule the named id of the style module to import
* @returns the style module's CSS text, or an empty string if the module does
* not exist
Expand Down Expand Up @@ -46,6 +47,8 @@ export function importStyleModule(styleModule: string): string {

/**
* Resets the cache using by `importStyleModule()`, primarily used for testing.
*
* @deprecated clearStyleModuleCache will be removed in the next major release.leModule will be removed in the next major release.
*/
export function clearStyleModuleCache() {
CACHED_STYLE_MODULES = new Map();
Expand Down
9 changes: 5 additions & 4 deletions styles/src/modules/inject-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
ViewEncapsulation
} from '@angular/core';
import { Router } from '@angular/router';
import { stylesFromModule } from '@polymer/polymer/lib/utils/style-gather';
import { whenSet } from '@codebakery/origami/util';
import { importStyleModule } from './import-style-module';
import { getStyleModulesFor } from './include-styles';
import { styleToEmulatedEncapsulation } from './style-to-emulated-encapsulation';
import { getTypeFor, scanComponentFactoryResolver } from './type-selectors';
Expand Down Expand Up @@ -104,9 +104,10 @@ export function patchRendererFactory(factory: RendererFactory2) {
const selector = element && element.localName;
if (selector && type && INJECTED_SELECTORS.indexOf(selector) === -1) {
const styleModules = getStyleModulesFor(getTypeFor(selector));
let styles = styleModules.map(styleModule =>
importStyleModule(styleModule)
);
let styles = styleModules.map(styleModule => {
const styleElements = stylesFromModule(styleModule);
return styleElements.map(e => e.innerText).join('\n');
});
switch (type.encapsulation) {
case ViewEncapsulation.Emulated:
default:
Expand Down

0 comments on commit f585ccd

Please sign in to comment.