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

Use tag-name-is-component helper to remove need for Menu::ItemElement backing class #91

Merged
merged 1 commit into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion addon/components/menu/item-element.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#let
(if this.tagNameIsComponent @tagName (element (or @tagName 'a')))
(if (tag-name-is-component @tagName) @tagName (element (or @tagName 'a')))
as |Tag|
}}
<Tag
Expand Down
7 changes: 0 additions & 7 deletions addon/components/menu/item-element.js

This file was deleted.

7 changes: 7 additions & 0 deletions addon/helpers/tag-name-is-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper } from '@ember/component/helper';

function tagNameIsComponent([as]) {
return typeof as === 'object';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want this to return true for things that aren't components?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically no, but it would be weird for someone to pass an object that isn't a component.

Perhaps there are some other things we could check for on the object? If not, I think this is likely good enough for now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, this is a quick win, we can make it more constrained later as the public API declares what is intended anyway

}

export default helper(tagNameIsComponent);
1 change: 1 addition & 0 deletions app/helpers/tag-name-is-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-headlessui/helpers/tag-name-is-component';