Browse Source

fix: avoid blocking first input event in IE when it shouldn't (#9297)

- the original bug in #7138 only happens for `<textarea>`
- the bug doesn't happen if placeholder has empty value

fix #9042, fix #9383
dev
nciont 6 years ago
committed by Evan You
parent
commit
0fb03b7831
  1. 4
      src/platforms/web/runtime/modules/attrs.js
  2. 18
      test/unit/features/directives/model-text.spec.js

4
src/platforms/web/runtime/modules/attrs.js

@ -98,8 +98,8 @@ function baseSetAttr (el, key, value) {
/* istanbul ignore if */
if (
isIE && !isIE9 &&
(el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') &&
key === 'placeholder' && !el.__ieph
el.tagName === 'TEXTAREA' &&
key === 'placeholder' && value !== '' && !el.__ieph
) {
const blocker = e => {
e.stopImmediatePropagation()

18
test/unit/features/directives/model-text.spec.js

@ -437,8 +437,8 @@ describe('Directive v-model text', () => {
})
}
// #7138
if (isIE && !isIE9) {
// #7138
it('should not fire input on initial render of textarea with placeholder in IE10/11', done => {
const el = document.createElement('div')
document.body.appendChild(el)
@ -452,5 +452,21 @@ describe('Directive v-model text', () => {
done()
}, 17)
})
// #9042
it('should not block the first input event when placeholder is empty', done => {
const el = document.createElement('div')
document.body.appendChild(el)
const vm = new Vue({
el,
data: { evtCount: 0 },
template: `<textarea placeholder="" @input="evtCount++"></textarea>`,
})
triggerEvent(vm.$el, 'input')
setTimeout(() => {
expect(vm.evtCount).toBe(1)
done()
}, 17)
})
}
})

Loading…
Cancel
Save