Skip to content

Commit

Permalink
Relax fa-layers restrictions on projected elements
Browse files Browse the repository at this point in the history
Silently dropping unsupported elements seems to create more pain then it generates benefit: it is confusing and does not support all use cases (for example fa-icon inside ng-container). It is better to relax it and assume that users only provide supported elements.

Fixes #283
  • Loading branch information
devoto13 committed Dec 11, 2020
1 parent d546906 commit e9e0549
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/lib/layers/layers.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,25 @@ describe('FaLayersComponent', () => {
fixture.detectChanges();
expect(queryByCss(fixture, 'fa-duotone-icon')).toBeTruthy();
});

it('should support icons wrapped into ng-container', () => {
@Component({
selector: 'fa-host',
template: `
<fa-layers>
<ng-container>
<fa-icon [icon]="faUser"></fa-icon>
<fa-layers-text [content]="'Dummy'" [styles]="{ color: 'Tomato' }"></fa-layers-text>
</ng-container>
</fa-layers>
`,
})
class HostComponent {
faUser = faUser;
}

const fixture = initTest(HostComponent);
fixture.detectChanges();
expect(queryByCss(fixture, 'fa-icon')).toBeTruthy();
});
});
3 changes: 2 additions & 1 deletion src/lib/layers/layers.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Component, ElementRef, HostBinding, Input, OnChanges, OnInit, Renderer2, SimpleChanges } from '@angular/core';
import { SizeProp } from '@fortawesome/fontawesome-svg-core';
import { FaConfig } from '../config';

/**
* Fontawesome layers.
*/
@Component({
selector: 'fa-layers',
template: `<ng-content select="fa-icon, fa-duotone-icon, fa-layers-text, fa-layers-counter"></ng-content>`,
template: `<ng-content></ng-content>`,
})
export class FaLayersComponent implements OnInit, OnChanges {
@Input() size?: SizeProp;
Expand Down

0 comments on commit e9e0549

Please sign in to comment.