Skip to content

Instantly share code, notes, and snippets.

@catwell
Created July 14, 2019 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catwell/0f5a8a781e3236d01af51d323272b110 to your computer and use it in GitHub Desktop.
Save catwell/0f5a8a781e3236d01af51d323272b110 to your computer and use it in GitHub Desktop.
avoid-flash-of-unstyled-slot-stencil
my-component {
display: none;
}
my-component[is-loaded] {
display: block;
}
@Component({
tag: 'my-component,
shadow: true,
})
export class MyComponent {
@Prop({reflect: true}) isLoaded : boolean;
componentDidLoad () : void {
this.isLoaded = true;
}
}
@catwell
Copy link
Author

catwell commented Jul 14, 2019

Better alternative but unsupported in IE / Edge:

my-component:not(:defined) {
  display: none;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment