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

Expose component as host #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions accepted/0000-component-as-host.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Expose internal component as host

## Summary

Allow dynamic components to expose internal element so all attributes, id and classes will apply directly to them instead of the host element.

## Motivation

It will allow to reduce boilerplate in configuration of dynamic components because standard attributes and properties
will be automatically redirected to correct internal component in template.

## Detailed Explanation

This will be useful when, for example, you have button in template and you want to allow to set attributes directly on it:

```html
<button orcExposeAsHost>{config.text}</button>
```

In this case directive `orcExposeAsHost` will make button element as `host` component and attributes from config will be set directly on it.

## Rationale and Alternatives

- Wiring configuration for default attributes manually to components.

## Implementation

Create directive named `orcExposeAsHost` that will take host component and expose it as host component.

Then `RenderItemComponent` will grab it and apply directives and attributes on it instead of real host component.

## Prior Art

None

## Unresolved Questions and Bikeshedding

- It's unclear how to get internal component as host before rendering real host component because all attributes already will be applied by that time

- It requires support from the upstream lib ng-dynamic-component to be able to provide custom ComponentInjector for different directives on dynamic components.