fix: input not trigger change compositionStart
parent
7f7511bf61
commit
7719c65169
|
@ -1 +1 @@
|
||||||
Subproject commit c5cc76b99aef8ba929575b6e0f7db82873ac3058
|
Subproject commit a24eac222a88e0c8fecfa739b07656e7e5b82a15
|
|
@ -1,21 +1,3 @@
|
||||||
/**
|
|
||||||
* Not type checking this file because flow doesn't like attaching
|
|
||||||
* properties to Elements.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const inBrowser = typeof window !== 'undefined';
|
|
||||||
export const UA = inBrowser && window.navigator.userAgent.toLowerCase();
|
|
||||||
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
|
|
||||||
function makeMap(str, expectsLowerCase) {
|
|
||||||
const map = Object.create(null);
|
|
||||||
const list = str.split(',');
|
|
||||||
for (let i = 0; i < list.length; i++) {
|
|
||||||
map[list[i]] = true;
|
|
||||||
}
|
|
||||||
return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
|
|
||||||
}
|
|
||||||
const isTextInputType = makeMap('text,number,password,search,email,tel,url');
|
|
||||||
|
|
||||||
function onCompositionStart(e) {
|
function onCompositionStart(e) {
|
||||||
e.target.composing = true;
|
e.target.composing = true;
|
||||||
}
|
}
|
||||||
|
@ -33,40 +15,21 @@ function trigger(el, type) {
|
||||||
el.dispatchEvent(e);
|
el.dispatchEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore if */
|
export function addEventListener(el, event, handler, options) {
|
||||||
if (isIE9) {
|
el.addEventListener(event, handler, options);
|
||||||
// http://www.matts411.com/post/internet-explorer-9-oninput/
|
|
||||||
document.addEventListener('selectionchange', () => {
|
|
||||||
const el = document.activeElement;
|
|
||||||
if (el && el.vmodel) {
|
|
||||||
trigger(el, 'input');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const antInput = {
|
||||||
export const antInput = {
|
created(el, binding) {
|
||||||
mounted(el, binding, vnode) {
|
if (!binding.modifiers || !binding.modifiers.lazy) {
|
||||||
if (vnode.type === 'textarea' || isTextInputType(el.type)) {
|
addEventListener(el, 'compositionstart', onCompositionStart);
|
||||||
if (!binding.modifiers || !binding.modifiers.lazy) {
|
addEventListener(el, 'compositionend', onCompositionEnd);
|
||||||
el.addEventListener('compositionstart', onCompositionStart);
|
// Safari < 10.2 & UIWebView doesn't fire compositionend when
|
||||||
el.addEventListener('compositionend', onCompositionEnd);
|
// switching focus before confirming composition choice
|
||||||
// Safari < 10.2 & UIWebView doesn't fire compositionend when
|
// this also fixes the issue where some browsers e.g. iOS Chrome
|
||||||
// switching focus before confirming composition choice
|
// fires "change" instead of "input" on autocomplete.
|
||||||
// this also fixes the issue where some browsers e.g. iOS Chrome
|
addEventListener(el, 'change', onCompositionEnd);
|
||||||
// fires "change" instead of "input" on autocomplete.
|
|
||||||
el.addEventListener('change', onCompositionEnd);
|
|
||||||
/* istanbul ignore if */
|
|
||||||
if (isIE9) {
|
|
||||||
el.vmodel = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default antInput;
|
||||||
install: app => {
|
|
||||||
antInput(app);
|
|
||||||
app.directive('ant-input', antInput);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { inject } from 'vue';
|
import { inject, withDirectives } from 'vue';
|
||||||
|
import antInputDirective from '../_util/antInputDirective';
|
||||||
import classNames from '../_util/classNames';
|
import classNames from '../_util/classNames';
|
||||||
import omit from 'omit.js';
|
import omit from 'omit.js';
|
||||||
import inputProps from './inputProps';
|
import inputProps from './inputProps';
|
||||||
|
@ -164,7 +165,7 @@ export default {
|
||||||
if (!inputProps.autofocus) {
|
if (!inputProps.autofocus) {
|
||||||
delete inputProps.autofocus;
|
delete inputProps.autofocus;
|
||||||
}
|
}
|
||||||
return <input {...inputProps} />;
|
return withDirectives(<input {...inputProps} />, [[antInputDirective]]);
|
||||||
},
|
},
|
||||||
clearPasswordValueAttribute() {
|
clearPasswordValueAttribute() {
|
||||||
// https://github.com/ant-design/ant-design/issues/20541
|
// https://github.com/ant-design/ant-design/issues/20541
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import demo from '../antdv-demo/docs/form/demo';
|
import demo from '../antdv-demo/docs/input/demo/basic.md';
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
demo,
|
demo,
|
||||||
|
|
Loading…
Reference in New Issue