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

Allow component interpolation without root element #878

Merged
merged 3 commits into from May 15, 2020
Merged

Allow component interpolation without root element #878

merged 3 commits into from May 15, 2020

Conversation

danimoh
Copy link
Contributor

@danimoh danimoh commented May 14, 2020

Component interpolation without a root element can now be enabled
by setting the tag prop to false.
Let me know if you prefer something else then value false, for example
a keyword like "none".
Value false would need to be specified as :tag="false", a keyword as
tag="none" which might read a little nicer.

Fixes #876

@kazupon
Copy link
Owner

kazupon commented May 14, 2020

Thank you for your PR!
This fix is ​​an enhancement, but we need to keep backward compatible.

<i18n> component tag prop is currently string type only.
https://kazupon.github.io/vue-i18n/api/#i18n-functional-component

My recommendation is that backwards compatibility can be maintained by also supporting boolean types. when passed boolean value (false or true), returning children.
If tag prop is nothing, it should be span.

The same goes for <i18n-n> component.

@danimoh
Copy link
Contributor Author

danimoh commented May 14, 2020

That makes sense.
What would a value of true stand for though?
Should the default be used for true which is a span?

Would you want to work on the additional changes to the documentation, i18n-n and support for true yourself?
That would likely be faster then me trying to figure it out.
But if you want, I can help of course.

@kazupon
Copy link
Owner

kazupon commented May 14, 2020

What would a value of true stand for though?

if tag prop value is true, it should be span, else false value, it should be returned children.

Should the default be used for true which is a span?

if tag prop is nothing, it should be true same.

Would you want to work on the additional changes to the documentation, i18n-n and support for true yourself?

I'm busy developing for vue-i18n-next, so I'm glad if you could help. 🙏

@danimoh
Copy link
Contributor Author

danimoh commented May 14, 2020

I changed the behavior for true as discussed and added support for i18n-n components without root element.
I also added tests and documentation for this feature.
I hope I built the docs correctly, please have a look.

@codecov-io
Copy link

Codecov Report

Merging #878 into v8.x will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             v8.x     #878   +/-   ##
=======================================
  Coverage   96.38%   96.38%           
=======================================
  Files          10       10           
  Lines         885      886    +1     
=======================================
+ Hits          853      854    +1     
  Misses         32       32           
Impacted Files Coverage Δ
src/components/interpolation.js 100.00% <ø> (ø)
src/components/number.js 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd3a032...97d452e. Read the comment docs.

Copy link
Owner

@kazupon kazupon left a comment

Choose a reason for hiding this comment

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

Thanks!

@kazupon kazupon merged commit 28c9514 into kazupon:v8.x May 15, 2020
@kazupon kazupon added the Type: Improvement Includes backwards-compatible fixes label May 15, 2020
danimoh added a commit to nimiq/hub that referenced this pull request May 15, 2020
Don't delete _i18n in beforeDestroy
(kazupon/vue-i18n#880):
Avoid that translations in long-running methods throw on
translations after destruction.

Allow component interpolation without root element
(kazupon/vue-i18n#878):
For fixed responsiveness of the mobile checkout cancel
button.
@danimoh danimoh mentioned this pull request May 15, 2020
danimoh added a commit to nimiq/hub that referenced this pull request Jun 15, 2020
Don't delete _i18n in beforeDestroy
(kazupon/vue-i18n#880):
Avoid that translations in long-running methods throw on
translations after destruction.

Allow component interpolation without root element
(kazupon/vue-i18n#878):
For fixed responsiveness of the mobile checkout cancel
button.
danimoh added a commit to nimiq/hub that referenced this pull request Jun 17, 2020
Don't delete _i18n in beforeDestroy
(kazupon/vue-i18n#880):
Avoid that translations in long-running methods throw on
translations after destruction.

Allow component interpolation without root element
(kazupon/vue-i18n#878):
For fixed responsiveness of the mobile checkout cancel
button.
mraveux pushed a commit to nimiq/hub that referenced this pull request Jun 22, 2020
Don't delete _i18n in beforeDestroy
(kazupon/vue-i18n#880):
Avoid that translations in long-running methods throw on
translations after destruction.

Allow component interpolation without root element
(kazupon/vue-i18n#878):
For fixed responsiveness of the mobile checkout cancel
button.
danimoh added a commit to nimiq/hub that referenced this pull request Jul 2, 2020
Don't delete _i18n in beforeDestroy
(kazupon/vue-i18n#880):
Avoid that translations in long-running methods throw on
translations after destruction.

Allow component interpolation without root element
(kazupon/vue-i18n#878):
For fixed responsiveness of the mobile checkout cancel
button.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged Type: Improvement Includes backwards-compatible fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't create component interpolation without a root element / tag
3 participants