Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering in <style> tags causes extra line breaks #1374

Open
NullVoxPopuli opened this issue Jan 16, 2022 · 5 comments
Open

Rendering in <style> tags causes extra line breaks #1374

NullVoxPopuli opened this issue Jan 16, 2022 · 5 comments

Comments

@NullVoxPopuli
Copy link
Contributor

NullVoxPopuli commented Jan 16, 2022

Code

    <div {{this.attachShadow}}></div>

    {{#if this.shadow}}
      {{#in-element this.shadow}}
        {{#unless @omitStyles}}
          <style type="text/css">
            @import '{{this.vendor}}';
            @import '{{this.app}}';
          </style>
        {{/unless}}

        {{yield}}
      {{/in-element}}
    {{/if}}

Output (just the style part)
image

Expected:

          <style type="text/css">
            @import '/assets/vendor.css';
            @import '/assets/limber.css';
          </style>
@NullVoxPopuli
Copy link
Contributor Author

idk how important this is, because behaviorally, everything works...
it just looks weird 🙃

@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Jan 16, 2022

This is my full component (in case anyone else comes across this and wants shadow dom fun):

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

interface Args {
  omitStyles: boolean;
}

export default class Shadowed extends Component<Args> {
  @tracked shadow?: ShadowRoot;

  vendor = '/assets/vendor.css';
  tailwind = '/assets/tailwind.css';
  app = '/assets/limber.css';

  attachShadow = (element: HTMLElement) => {
    this.shadow = element.attachShadow({ mode: 'open' });
  };

  <template>
    <div {{this.attachShadow}}></div>

    {{#if this.shadow}}
      {{#in-element this.shadow}}
        {{#unless @omitStyles}}
          <style type="text/css">
            @import '{{this.tailwind}}';
            @import '{{this.vendor}}';
            @import '{{this.app}}';
          </style>
        {{/unless}}

        {{yield}}
      {{/in-element}}
    {{/if}}
  </template>
}

@lifeart
Copy link
Contributor

lifeart commented Jan 16, 2022

Try:
@import '{{~this.tailwind~}}';

@NullVoxPopuli
Copy link
Contributor Author

Same results

@boris-petrov
Copy link
Contributor

I guess this is similar to those two issues - emberjs/ember.js#19602 and emberjs/ember.js#19603.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants