Skip to content

Commit fdebb0e

Browse files
committed
[Fix] Change event didn't fired on mac safari when value length grater than 3
1 parent a43fbb2 commit fdebb0e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/core.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ export function updateValue(
7878
vnode,
7979
{ emit = true, force = false, clean = false } = {}
8080
) {
81-
const { config } = el[CONFIG_KEY]
82-
let { oldValue } = el[CONFIG_KEY]
83-
let currentValue = vnode && vnode.props ? vnode.props.value : el.value
81+
let { config, oldValue } = el[CONFIG_KEY]
82+
let currentValue = vnode?.props?.value || el.value
8483

8584
if (force || oldValue !== currentValue) {
8685
const number = new NumberFormat(config).clean(clean && !config.reverseFill)
@@ -98,7 +97,7 @@ export function updateValue(
9897
}
9998
}
10099

101-
el[CONFIG_KEY].oldValue = masked
100+
el[CONFIG_KEY].masked = masked
102101
el.unmaskedValue = unmasked
103102

104103
// safari makes the cursor jump to the end if el.value gets assign even if to the same value
@@ -130,9 +129,9 @@ export function inputHandler(event) {
130129
event.stopPropagation()
131130

132131
let positionFromEnd = target.value.length - target.selectionEnd
133-
const { oldValue, config } = target[CONFIG_KEY]
132+
const { oldValue, config, masked } = target[CONFIG_KEY]
134133

135-
updateValue(target, null, { emit: false }, event)
134+
updateValue(target, null, { emit: false })
136135

137136
// updated cursor position
138137
positionFromEnd = Math.max(positionFromEnd, config.suffix.length)
@@ -141,6 +140,7 @@ export function inputHandler(event) {
141140
updateCursor(target, positionFromEnd)
142141

143142
if (oldValue !== target.value) {
143+
target[CONFIG_KEY].oldValue = masked
144144
target.dispatchEvent(FacadeInputEvent())
145145
}
146146
}
@@ -157,12 +157,12 @@ export function blurHandler(event) {
157157
if (detail?.facade) {
158158
return false
159159
}
160+
const { oldValue, masked } = target[CONFIG_KEY]
160161

161-
const { oldValue } = target[CONFIG_KEY]
162-
163-
updateValue(target, null, { force: true, emit: true, clean: true }, event)
162+
updateValue(target, null, { force: true, emit: true, clean: true })
164163

165164
if (oldValue !== target.value) {
165+
target[CONFIG_KEY].oldValue = masked
166166
target.dispatchEvent(FacadeChangeEvent())
167167
}
168168
}

0 commit comments

Comments
 (0)