Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Only run autosize only if directive is truthy.
Browse files Browse the repository at this point in the history
  • Loading branch information
benosman committed Apr 12, 2018
1 parent d889665 commit 07b5eff
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var autoSizeInput = require('autosize-input')
exports.install = function(Vue) {
Vue.directive('autosize', {
bind: function(el, binding) {
if (!binding.value) return
var tagName = el.tagName
if (tagName == 'TEXTAREA') {
autosize(el)
Expand All @@ -13,6 +14,7 @@ exports.install = function(Vue) {
},

componentUpdated: function(el, binding, vnode) {
if (!binding.value) return
var tagName = el.tagName
if (tagName == 'TEXTAREA') {
autosize.update(el)
Expand All @@ -21,7 +23,8 @@ exports.install = function(Vue) {
}
},

unbind: function(el) {
unbind: function(el, binding) {
if (!binding.value) return
autosize.destroy(el)
}
})
Expand Down

0 comments on commit 07b5eff

Please sign in to comment.