Skip to content

fix #7367: Replace isAndroid with window.ConpositionEvent. #7368

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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/directives/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { isTextInputType } from 'web/util/element'
import { looseEqual, looseIndexOf } from 'shared/util'
import { mergeVNodeHook } from 'core/vdom/helpers/index'
import { warn, isAndroid, isIE9, isIE, isEdge } from 'core/util/index'
import { warn, isIE9, isIE, isEdge } from 'core/util/index'

/* istanbul ignore if */
if (isIE9) {
Expand Down Expand Up @@ -39,7 +39,7 @@ const directive = {
// this also fixes the issue where some browsers e.g. iOS Chrome
// fires "change" instead of "input" on autocomplete.
el.addEventListener('change', onCompositionEnd)
if (!isAndroid) {
if (typeof window.CompositionEvent === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dectect this everytime is not a good idea.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor as your suggestion, thx : )

el.addEventListener('compositionstart', onCompositionStart)
el.addEventListener('compositionend', onCompositionEnd)
}
Expand Down
6 changes: 3 additions & 3 deletions test/unit/features/directives/model-text.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue'
import { isIE9, isIE, isAndroid } from 'core/util/env'
import { isIE9, isIE } from 'core/util/env'

describe('Directive v-model text', () => {
it('should update value both ways', done => {
Expand Down Expand Up @@ -183,7 +183,7 @@ describe('Directive v-model text', () => {
})
}

if (!isAndroid) {
if (typeof window.CompositionEvent === 'function') {
it('compositionevents', function (done) {
const vm = new Vue({
data: {
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('Directive v-model text', () => {
expect('conflicts with v-model').not.toHaveBeenWarned()
})

if (!isAndroid) {
if (!typeof window.CompositionEvent === 'function') {
it('does not trigger extra input events with single compositionend', () => {
const spy = jasmine.createSpy()
const vm = new Vue({
Expand Down