Skip to content

Commit

Permalink
feat(directive): simplify directive arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed Aug 8, 2019
1 parent c0bf0c7 commit ed4ccff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions src/directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { DirectiveBinding } from 'vue/types/options'
import { VNode } from 'vue/types/vnode'
import { warn } from './util/warn'

interface FluentDirectiveBinding {
key: string
arg: Object
attrs?: [string]
}

export default {
bind(el: HTMLElement, binding: DirectiveBinding, vnode: VNode) {
if (vnode.context === undefined) {
Expand All @@ -19,8 +13,6 @@ export default {
return
}

const directiveData = (binding.value as FluentDirectiveBinding) || {}

el.textContent = vnode.context.$t(binding.arg, directiveData.arg)
el.textContent = vnode.context.$t(binding.arg, binding.value)
}
}
2 changes: 1 addition & 1 deletion test/directive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('directive', () => {
data: () => ({
name: 'John'
}),
template: `<a v-t:link="{ arg: { name: 'John' } }" href="/foo">Fallback text</a>`
template: `<a v-t:link="{ name }" href="/foo">Fallback text</a>`
}

// Act
Expand Down

0 comments on commit ed4ccff

Please sign in to comment.