Skip to content

Commit

Permalink
Gate feature behind shareBuiltCSSWithAdoptedStyleSheets; update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bicknellr committed Apr 3, 2020
1 parent 2fc9062 commit bdd7658
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/mixins/element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
import '../utils/boot.js';

import { rootPath, strictTemplatePolicy, allowTemplateFromDomModule, legacyOptimizations, legacyWarnings, syncInitialRender, supportsAdoptingStyleSheets} from '../utils/settings.js';
import { rootPath, strictTemplatePolicy, allowTemplateFromDomModule, legacyOptimizations, legacyWarnings, syncInitialRender, supportsAdoptingStyleSheets, shareBuiltCSSWithAdoptedStyleSheets } from '../utils/settings.js';
import { dedupingMixin } from '../utils/mixin.js';
import { stylesFromTemplate, stylesFromModuleImports } from '../utils/style-gather.js';
import { pathFromUrl, resolveCss, resolveUrl } from '../utils/resolve-url.js';
Expand Down Expand Up @@ -304,7 +304,7 @@ export const ElementMixin = dedupingMixin(base => {
// potentially not shareable and sharing the ones that could be shared
// would require some coordination. To keep it simple, all the includes
// and styles are collapsed into a single shareable stylesheet.
if (builtCSS && supportsAdoptingStyleSheets) {
if (shareBuiltCSSWithAdoptedStyleSheets && builtCSS && supportsAdoptingStyleSheets) {
// Remove styles in template and make a shareable stylesheet
const styles = template.content.querySelectorAll('style');
if (styles) {
Expand Down
6 changes: 5 additions & 1 deletion test/unit/styling-build-adopted-stylesheets.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
<script src="wct-browser-config.js"></script>
<script src="../../node_modules/wct-browser-legacy/browser.js"></script>
<script type="module">
import { supportsAdoptingStyleSheets } from '../../lib/utils/settings.js';
import {
setShareBuiltCSSWithAdoptedStyleSheets,
supportsAdoptingStyleSheets,
} from '../../lib/utils/settings.js';
setShareBuiltCSSWithAdoptedStyleSheets(true);
window.supportsAdoptingStyleSheets = supportsAdoptingStyleSheets;
let define = window.customElements.define;
let order = [];
Expand Down

0 comments on commit bdd7658

Please sign in to comment.