Skip to content

Commit

Permalink
⚡ improvement(number): support data fall through in i18n-n (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon authored Mar 26, 2019
1 parent c09dcc1 commit 71cadbf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions examples/number-formatting/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<option value="en-US">en-US</option>
<option value="ja-JP">ja-JP</option>
</select>
<p>
{{ $t('money') }}:
<i18n-n :value="money" format="currency">
<div class="view">
<p class="label">{{ $t('money') }}:</p>
<i18n-n :value="money" format="currency" tag="p" class="money">
<template slot="decimal" slot-scope="props"><!-- do not render decimal separator --></template>
<span slot="fraction" slot-scope="props" style="vertical-align: super">{{ props.fraction }}</span>
</i18n-n>
</p>
</div>
</div>
<script>
var messages = {
Expand Down
6 changes: 5 additions & 1 deletion src/components/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export default {
return slot ? slot({ [part.type]: part.value, index, parts }) : part.value
})

return h(props.tag, values)
return h(props.tag, {
attrs: data.attrs,
'class': data['class'],
staticClass: data.staticClass
}, values)
}
}
2 changes: 1 addition & 1 deletion test/e2e/test/number.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
component: function (browser) {
number: function (browser) {
browser
.url('http://localhost:8080/examples/number/')
.waitForElementVisible('#app', 1000)
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/test/number_formatting.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = {
component: function (browser) {
'number_formatting': function (browser) {
browser
.url('http://localhost:8080/examples/number-formatting/')
.waitForElementVisible('#app', 1000)
.assert.containsText('p', 'お金: ¥1,000')
.assert.containsText('p.money', '¥1,000')
.click('select option[value=en-US]')
.assert.attributeContains('p', 'innerHTML', 'Money: $1,000<span style="vertical-align: super">00</span>')
.assert.attributeContains('p.money', 'innerHTML', '$1,000<span style="vertical-align: super;">00</span>')
.end()
}
}

0 comments on commit 71cadbf

Please sign in to comment.