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
Refactor Nav/Navbar/Dropdown's LinkTo components to not extend from Ember's LinkComponent #1455
Conversation
return; | ||
} | ||
|
||
params = params.slice(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't formally deprecated positional params for link params it seems. While this is now deprecated for Ember's original LinkComponent, we do not trigger this deprecation anymore. So we should deprecate this explicitly by ourselves I think. Should be a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't we dropped support for curly-bracket component invocation in v4? If so, there shouldn't be a public API to provide positional params to a component. Or did I missed something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't we dropped support for curly-bracket component invocation in v4
We haven't declared so, no. We dropped arguments for HTML attributes, and more or less recommended to use angle brackets, but haven't explicitly stopped support for curly invocation. At the time there was no reason for this, and this is still not deprecated from Ember's side AFAIK. Except for this positional arguments issue there is no reason why curly invocation should bother us, as long as Ember supports it we can basically not care about it.
We can choose to drop support in a next major, or just say that the use of our custom link component drops support for positional arguments and all the other things (currentWhen) that accidentally became part of our implementation due to extending from LinkComponent, whether or not we consider this a public API or not. (it's a "gray area" I guess)
IIRC you were more on the side of accepting major versions more often, right? So should we actually do this refactoring as part of a v5, with just this edge case-y thing as the (potentially, but rather rare) breaking change?
The deprecation in Canary is gone, but something else related to FastBoot is failing now... 🤔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for picking this one up!
Was wondering why you decided to have a base class, which is than extended. Wouldn't implementation be easier to follow and require less code duplication, if <BsLinkTo>
is invoked in templates instead of extending from it?
If we can avoid much of the complexity by dropping support for position params, currentWhen
and activeClass
arguments and may accept some differences in edge cases I would be fully onboard. I'm a little bit afraid of the maintenance burden if trying to exactly replicate current functionality.
return; | ||
} | ||
|
||
params = params.slice(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't we dropped support for curly-bracket component invocation in v4? If so, there shouldn't be a public API to provide positional params to a component. Or did I missed something?
addon/components/bs-nav/link-to.js
Outdated
@uses Mixins.ComponentChild | ||
@public | ||
*/ | ||
@classNames(macroCondition(getOwnConfig().isBS4) ? 'nav-link' : '') | ||
export default class NavLinkTo extends LinkComponent.extend(ComponentChild) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't the component render <BsLinkTo>
and passing the arguments forward instead of extending from it?
I just tried that, which made me remember why: doesn't work for positional arguments. However if we want to drop them anyway - as part of a breaking change or not, see my other comment - then this makes sense! |
I refactored this more, this is now yielding the BsLinkTo component directly, without extending it or even having to use a template-only wrapper. This still allows positional arguments, so no need for a semi-breaking change yet... Will still look if I can remove the old cruft from the BsLinkTo component, i.e. just use the public |
I have done this now as much as possible...
|
…mber's LinkComponent According to RFC671 and deprecations introduced in latest Ember Canary.
Finally CI is passing. @jelhan want to have another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good. Thanks a lot for working on this.
@replace={{@replace}} | ||
@disabled={{@disabled}} | ||
@current-when={{@current-when}} | ||
@activeClass={{@activeClass}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think <BsLinkTo>
supports @replace
, @current-when
and @activeClass
. I guess a left-over from an earlier iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will fix!
Co-authored-by: Jeldrik Hanschke <jelhan@users.noreply.github.com>
According to RFC671 and deprecations introduced in latest Ember Canary.
Should fix the last remaining deprecation, see #1440.