Skip to content

Commit 0fb03b7

Browse files
nciontyyx990803
authored andcommitted
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
1 parent 55bfb94 commit 0fb03b7

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ function baseSetAttr (el, key, value) {
9898
/* istanbul ignore if */
9999
if (
100100
isIE && !isIE9 &&
101-
(el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') &&
102-
key === 'placeholder' && !el.__ieph
101+
el.tagName === 'TEXTAREA' &&
102+
key === 'placeholder' && value !== '' && !el.__ieph
103103
) {
104104
const blocker = e => {
105105
e.stopImmediatePropagation()

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

+17-1
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ describe('Directive v-model text', () => {
437437
})
438438
}
439439

440-
// #7138
441440
if (isIE && !isIE9) {
441+
// #7138
442442
it('should not fire input on initial render of textarea with placeholder in IE10/11', done => {
443443
const el = document.createElement('div')
444444
document.body.appendChild(el)
@@ -452,5 +452,21 @@ describe('Directive v-model text', () => {
452452
done()
453453
}, 17)
454454
})
455+
456+
// #9042
457+
it('should not block the first input event when placeholder is empty', done => {
458+
const el = document.createElement('div')
459+
document.body.appendChild(el)
460+
const vm = new Vue({
461+
el,
462+
data: { evtCount: 0 },
463+
template: `<textarea placeholder="" @input="evtCount++"></textarea>`,
464+
})
465+
triggerEvent(vm.$el, 'input')
466+
setTimeout(() => {
467+
expect(vm.evtCount).toBe(1)
468+
done()
469+
}, 17)
470+
})
455471
}
456472
})

0 commit comments

Comments
 (0)