Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #9042, #7138: handle empty placeholder case in IE #9297

Merged
merged 3 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/platforms/web/runtime/modules/attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,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()
Expand Down
18 changes: 17 additions & 1 deletion test/unit/features/directives/model-text.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
})
}
})