@vue/runtime-dom 3.2.32 → 3.2.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { isString, isArray, hyphenate, capitalize, isSpecialBooleanAttr, include
4
4
 
5
5
  const svgNS = 'http://www.w3.org/2000/svg';
6
6
  const doc = (typeof document !== 'undefined' ? document : null);
7
- const templateContainer = doc && doc.createElement('template');
7
+ const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
8
8
  const nodeOps = {
9
9
  insert: (child, parent, anchor) => {
10
10
  parent.insertBefore(child, anchor || null);
@@ -155,6 +155,8 @@ function setStyle(style, name, val) {
155
155
  val.forEach(v => setStyle(style, name, v));
156
156
  }
157
157
  else {
158
+ if (val == null)
159
+ val = '';
158
160
  if (name.startsWith('--')) {
159
161
  // custom property definition
160
162
  style.setProperty(name, val);
@@ -249,31 +251,28 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
249
251
  }
250
252
  return;
251
253
  }
254
+ let needRemove = false;
252
255
  if (value === '' || value == null) {
253
256
  const type = typeof el[key];
254
257
  if (type === 'boolean') {
255
258
  // e.g. <select multiple> compiles to { multiple: '' }
256
- el[key] = includeBooleanAttr(value);
257
- return;
259
+ value = includeBooleanAttr(value);
258
260
  }
259
261
  else if (value == null && type === 'string') {
260
262
  // e.g. <div :id="null">
261
- el[key] = '';
262
- el.removeAttribute(key);
263
- return;
263
+ value = '';
264
+ needRemove = true;
264
265
  }
265
266
  else if (type === 'number') {
266
267
  // e.g. <img :width="null">
267
268
  // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
268
- try {
269
- el[key] = 0;
270
- }
271
- catch (_a) { }
272
- el.removeAttribute(key);
273
- return;
269
+ value = 0;
270
+ needRemove = true;
274
271
  }
275
272
  }
276
- // some properties perform value validation and throw
273
+ // some properties perform value validation and throw,
274
+ // some properties has getter, no setter, will error in 'use strict'
275
+ // eg. <select :type="null"></select> <select :willValidate="null"></select>
277
276
  try {
278
277
  el[key] = value;
279
278
  }
@@ -283,31 +282,35 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
283
282
  `value ${value} is invalid.`, e);
284
283
  }
285
284
  }
285
+ needRemove && el.removeAttribute(key);
286
286
  }
287
287
 
288
288
  // Async edge case fix requires storing an event listener's attach timestamp.
289
- let _getNow = Date.now;
290
- let skipTimestampCheck = false;
291
- if (typeof window !== 'undefined') {
292
- // Determine what event timestamp the browser is using. Annoyingly, the
293
- // timestamp can either be hi-res (relative to page load) or low-res
294
- // (relative to UNIX epoch), so in order to compare time we have to use the
295
- // same timestamp type when saving the flush timestamp.
296
- if (_getNow() > document.createEvent('Event').timeStamp) {
297
- // if the low-res timestamp which is bigger than the event timestamp
298
- // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
299
- // and we need to use the hi-res version for event listeners as well.
300
- _getNow = () => performance.now();
301
- }
302
- // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
303
- // and does not fire microtasks in between event propagation, so safe to exclude.
304
- const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
305
- skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
306
- }
289
+ const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
290
+ let _getNow = Date.now;
291
+ let skipTimestampCheck = false;
292
+ if (typeof window !== 'undefined') {
293
+ // Determine what event timestamp the browser is using. Annoyingly, the
294
+ // timestamp can either be hi-res (relative to page load) or low-res
295
+ // (relative to UNIX epoch), so in order to compare time we have to use the
296
+ // same timestamp type when saving the flush timestamp.
297
+ if (Date.now() > document.createEvent('Event').timeStamp) {
298
+ // if the low-res timestamp which is bigger than the event timestamp
299
+ // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
300
+ // and we need to use the hi-res version for event listeners as well.
301
+ _getNow = () => performance.now();
302
+ }
303
+ // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
304
+ // and does not fire microtasks in between event propagation, so safe to exclude.
305
+ const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
306
+ skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
307
+ }
308
+ return [_getNow, skipTimestampCheck];
309
+ })();
307
310
  // To avoid the overhead of repeatedly calling performance.now(), we cache
308
311
  // and use the same timestamp for all event listeners attached in the same tick.
309
312
  let cachedNow = 0;
310
- const p = Promise.resolve();
313
+ const p = /*#__PURE__*/ Promise.resolve();
311
314
  const reset = () => {
312
315
  cachedNow = 0;
313
316
  };
@@ -432,13 +435,13 @@ function shouldSetAsProp(el, key, value, isSVG) {
432
435
  }
433
436
  return false;
434
437
  }
435
- // spellcheck and draggable are numerated attrs, however their
436
- // corresponding DOM properties are actually booleans - this leads to
437
- // setting it with a string "false" value leading it to be coerced to
438
- // `true`, so we need to always treat them as attributes.
438
+ // these are enumerated attrs, however their corresponding DOM properties
439
+ // are actually booleans - this leads to setting it with a string "false"
440
+ // value leading it to be coerced to `true`, so we need to always treat
441
+ // them as attributes.
439
442
  // Note that `contentEditable` doesn't have this problem: its DOM
440
443
  // property is also enumerated string values.
441
- if (key === 'spellcheck' || key === 'draggable') {
444
+ if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
442
445
  return false;
443
446
  }
444
447
  // #1787, #2840 form property on form elements is readonly and must be set as
@@ -461,11 +464,11 @@ function shouldSetAsProp(el, key, value, isSVG) {
461
464
  return key in el;
462
465
  }
463
466
 
464
- function defineCustomElement(options, hydate) {
467
+ function defineCustomElement(options, hydrate) {
465
468
  const Comp = defineComponent(options);
466
469
  class VueCustomElement extends VueElement {
467
470
  constructor(initialProps) {
468
- super(Comp, initialProps, hydate);
471
+ super(Comp, initialProps, hydrate);
469
472
  }
470
473
  }
471
474
  VueCustomElement.def = Comp;
@@ -827,7 +830,10 @@ function resolveTransitionProps(rawProps) {
827
830
  removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
828
831
  done && done();
829
832
  };
833
+ let isLeaving = false;
830
834
  const finishLeave = (el, done) => {
835
+ isLeaving = false;
836
+ removeTransitionClass(el, leaveFromClass);
831
837
  removeTransitionClass(el, leaveToClass);
832
838
  removeTransitionClass(el, leaveActiveClass);
833
839
  done && done();
@@ -860,12 +866,17 @@ function resolveTransitionProps(rawProps) {
860
866
  onEnter: makeEnterHook(false),
861
867
  onAppear: makeEnterHook(true),
862
868
  onLeave(el, done) {
869
+ isLeaving = true;
863
870
  const resolve = () => finishLeave(el, done);
864
871
  addTransitionClass(el, leaveFromClass);
865
872
  // force reflow so *-leave-from classes immediately take effect (#2593)
866
873
  forceReflow();
867
874
  addTransitionClass(el, leaveActiveClass);
868
875
  nextFrame(() => {
876
+ if (!isLeaving) {
877
+ // cancelled
878
+ return;
879
+ }
869
880
  removeTransitionClass(el, leaveFromClass);
870
881
  addTransitionClass(el, leaveToClass);
871
882
  if (!hasExplicitCallback(onLeave)) {
@@ -1158,7 +1169,8 @@ function hasCSSTransform(el, root, moveClass) {
1158
1169
  }
1159
1170
 
1160
1171
  const getModelAssigner = (vnode) => {
1161
- const fn = vnode.props['onUpdate:modelValue'];
1172
+ const fn = vnode.props['onUpdate:modelValue'] ||
1173
+ (false );
1162
1174
  return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
1163
1175
  };
1164
1176
  function onCompositionStart(e) {
@@ -1168,14 +1180,9 @@ function onCompositionEnd(e) {
1168
1180
  const target = e.target;
1169
1181
  if (target.composing) {
1170
1182
  target.composing = false;
1171
- trigger(target, 'input');
1183
+ target.dispatchEvent(new Event('input'));
1172
1184
  }
1173
1185
  }
1174
- function trigger(el, type) {
1175
- const e = document.createEvent('HTMLEvents');
1176
- e.initEvent(type, true, true);
1177
- el.dispatchEvent(e);
1178
- }
1179
1186
  // We are exporting the v-model runtime directly as vnode hooks so that it can
1180
1187
  // be tree-shaken in case v-model is never used.
1181
1188
  const vModelText = {
@@ -1189,7 +1196,7 @@ const vModelText = {
1189
1196
  if (trim) {
1190
1197
  domValue = domValue.trim();
1191
1198
  }
1192
- else if (castToNumber) {
1199
+ if (castToNumber) {
1193
1200
  domValue = toNumber(domValue);
1194
1201
  }
1195
1202
  el._assign(domValue);
@@ -1218,7 +1225,7 @@ const vModelText = {
1218
1225
  // avoid clearing unresolved text. #2302
1219
1226
  if (el.composing)
1220
1227
  return;
1221
- if (document.activeElement === el) {
1228
+ if (document.activeElement === el && el.type !== 'range') {
1222
1229
  if (lazy) {
1223
1230
  return;
1224
1231
  }
@@ -1389,27 +1396,25 @@ const vModelDynamic = {
1389
1396
  callModelHook(el, binding, vnode, prevVNode, 'updated');
1390
1397
  }
1391
1398
  };
1392
- function callModelHook(el, binding, vnode, prevVNode, hook) {
1393
- let modelToUse;
1394
- switch (el.tagName) {
1399
+ function resolveDynamicModel(tagName, type) {
1400
+ switch (tagName) {
1395
1401
  case 'SELECT':
1396
- modelToUse = vModelSelect;
1397
- break;
1402
+ return vModelSelect;
1398
1403
  case 'TEXTAREA':
1399
- modelToUse = vModelText;
1400
- break;
1404
+ return vModelText;
1401
1405
  default:
1402
- switch (vnode.props && vnode.props.type) {
1406
+ switch (type) {
1403
1407
  case 'checkbox':
1404
- modelToUse = vModelCheckbox;
1405
- break;
1408
+ return vModelCheckbox;
1406
1409
  case 'radio':
1407
- modelToUse = vModelRadio;
1408
- break;
1410
+ return vModelRadio;
1409
1411
  default:
1410
- modelToUse = vModelText;
1412
+ return vModelText;
1411
1413
  }
1412
1414
  }
1415
+ }
1416
+ function callModelHook(el, binding, vnode, prevVNode, hook) {
1417
+ const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
1413
1418
  const fn = modelToUse[hook];
1414
1419
  fn && fn(el, binding, vnode, prevVNode);
1415
1420
  }
@@ -1437,6 +1442,17 @@ function initVModelForSSR() {
1437
1442
  return { checked: true };
1438
1443
  }
1439
1444
  };
1445
+ vModelDynamic.getSSRProps = (binding, vnode) => {
1446
+ if (typeof vnode.type !== 'string') {
1447
+ return;
1448
+ }
1449
+ const modelToUse = resolveDynamicModel(
1450
+ // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
1451
+ vnode.type.toUpperCase(), vnode.props && vnode.props.type);
1452
+ if (modelToUse.getSSRProps) {
1453
+ return modelToUse.getSSRProps(binding, vnode);
1454
+ }
1455
+ };
1440
1456
  }
1441
1457
 
1442
1458
  const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
@@ -1543,7 +1559,7 @@ function initVShowForSSR() {
1543
1559
  };
1544
1560
  }
1545
1561
 
1546
- const rendererOptions = extend({ patchProp }, nodeOps);
1562
+ const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
1547
1563
  // lazy create the renderer - this makes core renderer logic tree-shakable
1548
1564
  // in case the user only imports reactivity utilities from Vue.
1549
1565
  let renderer;