@vue/runtime-dom 3.2.44 → 3.2.46

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.
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var runtimeCore = require('@vue/runtime-core');
6
4
  var shared = require('@vue/shared');
7
5
 
@@ -107,9 +105,6 @@ function patchStyle(el, prev, next) {
107
105
  const style = el.style;
108
106
  const isCssString = shared.isString(next);
109
107
  if (next && !isCssString) {
110
- for (const key in next) {
111
- setStyle(style, key, next[key]);
112
- }
113
108
  if (prev && !shared.isString(prev)) {
114
109
  for (const key in prev) {
115
110
  if (next[key] == null) {
@@ -117,6 +112,9 @@ function patchStyle(el, prev, next) {
117
112
  }
118
113
  }
119
114
  }
115
+ for (const key in next) {
116
+ setStyle(style, key, next[key]);
117
+ }
120
118
  }
121
119
  else {
122
120
  const currentDisplay = style.display;
@@ -479,12 +477,21 @@ class VueElement extends BaseClass {
479
477
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
480
478
  }
481
479
  this.attachShadow({ mode: 'open' });
480
+ if (!this._def.__asyncLoader) {
481
+ // for sync component defs we can immediately resolve props
482
+ this._resolveProps(this._def);
483
+ }
482
484
  }
483
485
  }
484
486
  connectedCallback() {
485
487
  this._connected = true;
486
488
  if (!this._instance) {
487
- this._resolveDef();
489
+ if (this._resolved) {
490
+ this._update();
491
+ }
492
+ else {
493
+ this._resolveDef();
494
+ }
488
495
  }
489
496
  }
490
497
  disconnectedCallback() {
@@ -500,9 +507,6 @@ class VueElement extends BaseClass {
500
507
  * resolve inner component definition (handle possible async component)
501
508
  */
502
509
  _resolveDef() {
503
- if (this._resolved) {
504
- return;
505
- }
506
510
  this._resolved = true;
507
511
  // set initial attrs
508
512
  for (let i = 0; i < this.attributes.length; i++) {
@@ -514,38 +518,26 @@ class VueElement extends BaseClass {
514
518
  this._setAttr(m.attributeName);
515
519
  }
516
520
  }).observe(this, { attributes: true });
517
- const resolve = (def) => {
518
- const { props = {}, styles } = def;
519
- const hasOptions = !shared.isArray(props);
520
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
521
+ const resolve = (def, isAsync = false) => {
522
+ const { props, styles } = def;
521
523
  // cast Number-type props set before resolve
522
524
  let numberProps;
523
- if (hasOptions) {
524
- for (const key in this._props) {
525
+ if (props && !shared.isArray(props)) {
526
+ for (const key in props) {
525
527
  const opt = props[key];
526
528
  if (opt === Number || (opt && opt.type === Number)) {
527
- this._props[key] = shared.toNumber(this._props[key]);
528
- (numberProps || (numberProps = Object.create(null)))[key] = true;
529
+ if (key in this._props) {
530
+ this._props[key] = shared.toNumber(this._props[key]);
531
+ }
532
+ (numberProps || (numberProps = Object.create(null)))[shared.camelize(key)] = true;
529
533
  }
530
534
  }
531
535
  }
532
536
  this._numberProps = numberProps;
533
- // check if there are props set pre-upgrade or connect
534
- for (const key of Object.keys(this)) {
535
- if (key[0] !== '_') {
536
- this._setProp(key, this[key], true, false);
537
- }
538
- }
539
- // defining getter/setters on prototype
540
- for (const key of rawKeys.map(shared.camelize)) {
541
- Object.defineProperty(this, key, {
542
- get() {
543
- return this._getProp(key);
544
- },
545
- set(val) {
546
- this._setProp(key, val);
547
- }
548
- });
537
+ if (isAsync) {
538
+ // defining getter/setters on prototype
539
+ // for sync defs, this already happened in the constructor
540
+ this._resolveProps(def);
549
541
  }
550
542
  // apply CSS
551
543
  this._applyStyles(styles);
@@ -554,12 +546,33 @@ class VueElement extends BaseClass {
554
546
  };
555
547
  const asyncDef = this._def.__asyncLoader;
556
548
  if (asyncDef) {
557
- asyncDef().then(resolve);
549
+ asyncDef().then(def => resolve(def, true));
558
550
  }
559
551
  else {
560
552
  resolve(this._def);
561
553
  }
562
554
  }
555
+ _resolveProps(def) {
556
+ const { props } = def;
557
+ const declaredPropKeys = shared.isArray(props) ? props : Object.keys(props || {});
558
+ // check if there are props set pre-upgrade or connect
559
+ for (const key of Object.keys(this)) {
560
+ if (key[0] !== '_' && declaredPropKeys.includes(key)) {
561
+ this._setProp(key, this[key], true, false);
562
+ }
563
+ }
564
+ // defining getter/setters on prototype
565
+ for (const key of declaredPropKeys.map(shared.camelize)) {
566
+ Object.defineProperty(this, key, {
567
+ get() {
568
+ return this._getProp(key);
569
+ },
570
+ set(val) {
571
+ this._setProp(key, val);
572
+ }
573
+ });
574
+ }
575
+ }
563
576
  _setAttr(key) {
564
577
  let value = this.getAttribute(key);
565
578
  const camelKey = shared.camelize(key);
@@ -615,27 +628,31 @@ class VueElement extends BaseClass {
615
628
  this._styles.length = 0;
616
629
  }
617
630
  this._applyStyles(newStyles);
618
- // if this is an async component, ceReload is called from the inner
619
- // component so no need to reload the async wrapper
620
- if (!this._def.__asyncLoader) {
621
- // reload
622
- this._instance = null;
623
- this._update();
624
- }
631
+ this._instance = null;
632
+ this._update();
625
633
  };
626
634
  }
627
- // intercept emit
628
- instance.emit = (event, ...args) => {
635
+ const dispatch = (event, args) => {
629
636
  this.dispatchEvent(new CustomEvent(event, {
630
637
  detail: args
631
638
  }));
632
639
  };
640
+ // intercept emit
641
+ instance.emit = (event, ...args) => {
642
+ // dispatch both the raw and hyphenated versions of an event
643
+ // to match Vue behavior
644
+ dispatch(event, args);
645
+ if (shared.hyphenate(event) !== event) {
646
+ dispatch(shared.hyphenate(event), args);
647
+ }
648
+ };
633
649
  // locate nearest Vue custom element parent for provide/inject
634
650
  let parent = this;
635
651
  while ((parent =
636
652
  parent && (parent.parentNode || parent.host))) {
637
653
  if (parent instanceof VueElement) {
638
654
  instance.parent = parent._instance;
655
+ instance.provides = parent._instance.provides;
639
656
  break;
640
657
  }
641
658
  }
@@ -839,18 +856,10 @@ function normalizeDuration(duration) {
839
856
  }
840
857
  function NumberOf(val) {
841
858
  const res = shared.toNumber(val);
842
- validateDuration(res);
843
- return res;
844
- }
845
- function validateDuration(val) {
846
- if (typeof val !== 'number') {
847
- runtimeCore.warn(`<transition> explicit duration is not a valid number - ` +
848
- `got ${JSON.stringify(val)}.`);
849
- }
850
- else if (isNaN(val)) {
851
- runtimeCore.warn(`<transition> explicit duration is NaN - ` +
852
- 'the duration expression might be incorrect.');
859
+ {
860
+ runtimeCore.assertNumber(res, '<transition> explicit duration');
853
861
  }
862
+ return res;
854
863
  }
855
864
  function addTransitionClass(el, cls) {
856
865
  cls.split(/\s+/).forEach(c => c && el.classList.add(c));
@@ -1047,6 +1056,14 @@ const TransitionGroupImpl = {
1047
1056
  };
1048
1057
  }
1049
1058
  };
1059
+ /**
1060
+ * TransitionGroup does not support "mode" so we need to remove it from the
1061
+ * props declarations, but direct delete operation is considered a side effect
1062
+ * and will make the entire transition feature non-tree-shakeable, so we do it
1063
+ * in a function and mark the function's invocation as pure.
1064
+ */
1065
+ const removeMode = (props) => delete props.mode;
1066
+ /*#__PURE__*/ removeMode(TransitionGroupImpl.props);
1050
1067
  const TransitionGroup = TransitionGroupImpl;
1051
1068
  function callPendingCbs(c) {
1052
1069
  const el = c.el;
@@ -1122,7 +1139,7 @@ const vModelText = {
1122
1139
  domValue = domValue.trim();
1123
1140
  }
1124
1141
  if (castToNumber) {
1125
- domValue = shared.toNumber(domValue);
1142
+ domValue = shared.looseToNumber(domValue);
1126
1143
  }
1127
1144
  el._assign(domValue);
1128
1145
  });
@@ -1157,7 +1174,8 @@ const vModelText = {
1157
1174
  if (trim && el.value.trim() === value) {
1158
1175
  return;
1159
1176
  }
1160
- if ((number || el.type === 'number') && shared.toNumber(el.value) === value) {
1177
+ if ((number || el.type === 'number') &&
1178
+ shared.looseToNumber(el.value) === value) {
1161
1179
  return;
1162
1180
  }
1163
1181
  }
@@ -1246,7 +1264,7 @@ const vModelSelect = {
1246
1264
  addEventListener(el, 'change', () => {
1247
1265
  const selectedVal = Array.prototype.filter
1248
1266
  .call(el.options, (o) => o.selected)
1249
- .map((o) => number ? shared.toNumber(getValue(o)) : getValue(o));
1267
+ .map((o) => number ? shared.looseToNumber(getValue(o)) : getValue(o));
1250
1268
  el._assign(el.multiple
1251
1269
  ? isSetModel
1252
1270
  ? new Set(selectedVal)
@@ -1619,9 +1637,6 @@ const initDirectivesForSSR = () => {
1619
1637
  }
1620
1638
  ;
1621
1639
 
1622
- Object.keys(runtimeCore).forEach(function (k) {
1623
- if (k !== 'default') exports[k] = runtimeCore[k];
1624
- });
1625
1640
  exports.Transition = Transition;
1626
1641
  exports.TransitionGroup = TransitionGroup;
1627
1642
  exports.VueElement = VueElement;
@@ -1642,3 +1657,6 @@ exports.vModelText = vModelText;
1642
1657
  exports.vShow = vShow;
1643
1658
  exports.withKeys = withKeys;
1644
1659
  exports.withModifiers = withModifiers;
1660
+ Object.keys(runtimeCore).forEach(function(k) {
1661
+ if (k !== 'default') exports[k] = runtimeCore[k];
1662
+ });
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var runtimeCore = require('@vue/runtime-core');
6
4
  var shared = require('@vue/shared');
7
5
 
@@ -107,9 +105,6 @@ function patchStyle(el, prev, next) {
107
105
  const style = el.style;
108
106
  const isCssString = shared.isString(next);
109
107
  if (next && !isCssString) {
110
- for (const key in next) {
111
- setStyle(style, key, next[key]);
112
- }
113
108
  if (prev && !shared.isString(prev)) {
114
109
  for (const key in prev) {
115
110
  if (next[key] == null) {
@@ -117,6 +112,9 @@ function patchStyle(el, prev, next) {
117
112
  }
118
113
  }
119
114
  }
115
+ for (const key in next) {
116
+ setStyle(style, key, next[key]);
117
+ }
120
118
  }
121
119
  else {
122
120
  const currentDisplay = style.display;
@@ -464,12 +462,21 @@ class VueElement extends BaseClass {
464
462
  }
465
463
  else {
466
464
  this.attachShadow({ mode: 'open' });
465
+ if (!this._def.__asyncLoader) {
466
+ // for sync component defs we can immediately resolve props
467
+ this._resolveProps(this._def);
468
+ }
467
469
  }
468
470
  }
469
471
  connectedCallback() {
470
472
  this._connected = true;
471
473
  if (!this._instance) {
472
- this._resolveDef();
474
+ if (this._resolved) {
475
+ this._update();
476
+ }
477
+ else {
478
+ this._resolveDef();
479
+ }
473
480
  }
474
481
  }
475
482
  disconnectedCallback() {
@@ -485,9 +492,6 @@ class VueElement extends BaseClass {
485
492
  * resolve inner component definition (handle possible async component)
486
493
  */
487
494
  _resolveDef() {
488
- if (this._resolved) {
489
- return;
490
- }
491
495
  this._resolved = true;
492
496
  // set initial attrs
493
497
  for (let i = 0; i < this.attributes.length; i++) {
@@ -499,38 +503,26 @@ class VueElement extends BaseClass {
499
503
  this._setAttr(m.attributeName);
500
504
  }
501
505
  }).observe(this, { attributes: true });
502
- const resolve = (def) => {
503
- const { props = {}, styles } = def;
504
- const hasOptions = !shared.isArray(props);
505
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
506
+ const resolve = (def, isAsync = false) => {
507
+ const { props, styles } = def;
506
508
  // cast Number-type props set before resolve
507
509
  let numberProps;
508
- if (hasOptions) {
509
- for (const key in this._props) {
510
+ if (props && !shared.isArray(props)) {
511
+ for (const key in props) {
510
512
  const opt = props[key];
511
513
  if (opt === Number || (opt && opt.type === Number)) {
512
- this._props[key] = shared.toNumber(this._props[key]);
513
- (numberProps || (numberProps = Object.create(null)))[key] = true;
514
+ if (key in this._props) {
515
+ this._props[key] = shared.toNumber(this._props[key]);
516
+ }
517
+ (numberProps || (numberProps = Object.create(null)))[shared.camelize(key)] = true;
514
518
  }
515
519
  }
516
520
  }
517
521
  this._numberProps = numberProps;
518
- // check if there are props set pre-upgrade or connect
519
- for (const key of Object.keys(this)) {
520
- if (key[0] !== '_') {
521
- this._setProp(key, this[key], true, false);
522
- }
523
- }
524
- // defining getter/setters on prototype
525
- for (const key of rawKeys.map(shared.camelize)) {
526
- Object.defineProperty(this, key, {
527
- get() {
528
- return this._getProp(key);
529
- },
530
- set(val) {
531
- this._setProp(key, val);
532
- }
533
- });
522
+ if (isAsync) {
523
+ // defining getter/setters on prototype
524
+ // for sync defs, this already happened in the constructor
525
+ this._resolveProps(def);
534
526
  }
535
527
  // apply CSS
536
528
  this._applyStyles(styles);
@@ -539,12 +531,33 @@ class VueElement extends BaseClass {
539
531
  };
540
532
  const asyncDef = this._def.__asyncLoader;
541
533
  if (asyncDef) {
542
- asyncDef().then(resolve);
534
+ asyncDef().then(def => resolve(def, true));
543
535
  }
544
536
  else {
545
537
  resolve(this._def);
546
538
  }
547
539
  }
540
+ _resolveProps(def) {
541
+ const { props } = def;
542
+ const declaredPropKeys = shared.isArray(props) ? props : Object.keys(props || {});
543
+ // check if there are props set pre-upgrade or connect
544
+ for (const key of Object.keys(this)) {
545
+ if (key[0] !== '_' && declaredPropKeys.includes(key)) {
546
+ this._setProp(key, this[key], true, false);
547
+ }
548
+ }
549
+ // defining getter/setters on prototype
550
+ for (const key of declaredPropKeys.map(shared.camelize)) {
551
+ Object.defineProperty(this, key, {
552
+ get() {
553
+ return this._getProp(key);
554
+ },
555
+ set(val) {
556
+ this._setProp(key, val);
557
+ }
558
+ });
559
+ }
560
+ }
548
561
  _setAttr(key) {
549
562
  let value = this.getAttribute(key);
550
563
  const camelKey = shared.camelize(key);
@@ -591,18 +604,27 @@ class VueElement extends BaseClass {
591
604
  vnode.ce = instance => {
592
605
  this._instance = instance;
593
606
  instance.isCE = true;
594
- // intercept emit
595
- instance.emit = (event, ...args) => {
607
+ const dispatch = (event, args) => {
596
608
  this.dispatchEvent(new CustomEvent(event, {
597
609
  detail: args
598
610
  }));
599
611
  };
612
+ // intercept emit
613
+ instance.emit = (event, ...args) => {
614
+ // dispatch both the raw and hyphenated versions of an event
615
+ // to match Vue behavior
616
+ dispatch(event, args);
617
+ if (shared.hyphenate(event) !== event) {
618
+ dispatch(shared.hyphenate(event), args);
619
+ }
620
+ };
600
621
  // locate nearest Vue custom element parent for provide/inject
601
622
  let parent = this;
602
623
  while ((parent =
603
624
  parent && (parent.parentNode || parent.host))) {
604
625
  if (parent instanceof VueElement) {
605
626
  instance.parent = parent._instance;
627
+ instance.provides = parent._instance.provides;
606
628
  break;
607
629
  }
608
630
  }
@@ -993,6 +1015,14 @@ const TransitionGroupImpl = {
993
1015
  };
994
1016
  }
995
1017
  };
1018
+ /**
1019
+ * TransitionGroup does not support "mode" so we need to remove it from the
1020
+ * props declarations, but direct delete operation is considered a side effect
1021
+ * and will make the entire transition feature non-tree-shakeable, so we do it
1022
+ * in a function and mark the function's invocation as pure.
1023
+ */
1024
+ const removeMode = (props) => delete props.mode;
1025
+ /*#__PURE__*/ removeMode(TransitionGroupImpl.props);
996
1026
  const TransitionGroup = TransitionGroupImpl;
997
1027
  function callPendingCbs(c) {
998
1028
  const el = c.el;
@@ -1068,7 +1098,7 @@ const vModelText = {
1068
1098
  domValue = domValue.trim();
1069
1099
  }
1070
1100
  if (castToNumber) {
1071
- domValue = shared.toNumber(domValue);
1101
+ domValue = shared.looseToNumber(domValue);
1072
1102
  }
1073
1103
  el._assign(domValue);
1074
1104
  });
@@ -1103,7 +1133,8 @@ const vModelText = {
1103
1133
  if (trim && el.value.trim() === value) {
1104
1134
  return;
1105
1135
  }
1106
- if ((number || el.type === 'number') && shared.toNumber(el.value) === value) {
1136
+ if ((number || el.type === 'number') &&
1137
+ shared.looseToNumber(el.value) === value) {
1107
1138
  return;
1108
1139
  }
1109
1140
  }
@@ -1192,7 +1223,7 @@ const vModelSelect = {
1192
1223
  addEventListener(el, 'change', () => {
1193
1224
  const selectedVal = Array.prototype.filter
1194
1225
  .call(el.options, (o) => o.selected)
1195
- .map((o) => number ? shared.toNumber(getValue(o)) : getValue(o));
1226
+ .map((o) => number ? shared.looseToNumber(getValue(o)) : getValue(o));
1196
1227
  el._assign(el.multiple
1197
1228
  ? isSetModel
1198
1229
  ? new Set(selectedVal)
@@ -1507,9 +1538,6 @@ const initDirectivesForSSR = () => {
1507
1538
  }
1508
1539
  ;
1509
1540
 
1510
- Object.keys(runtimeCore).forEach(function (k) {
1511
- if (k !== 'default') exports[k] = runtimeCore[k];
1512
- });
1513
1541
  exports.Transition = Transition;
1514
1542
  exports.TransitionGroup = TransitionGroup;
1515
1543
  exports.VueElement = VueElement;
@@ -1530,3 +1558,6 @@ exports.vModelText = vModelText;
1530
1558
  exports.vShow = vShow;
1531
1559
  exports.withKeys = withKeys;
1532
1560
  exports.withModifiers = withModifiers;
1561
+ Object.keys(runtimeCore).forEach(function(k) {
1562
+ if (k !== 'default') exports[k] = runtimeCore[k];
1563
+ });
@@ -142,6 +142,7 @@ export declare class VueElement extends BaseClass {
142
142
  * resolve inner component definition (handle possible async component)
143
143
  */
144
144
  private _resolveDef;
145
+ private _resolveProps;
145
146
  protected _setAttr(key: string): void;
146
147
  /* Excluded from this release type: _getProp */
147
148
  /* Excluded from this release type: _setProp */
@@ -480,6 +481,17 @@ export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> {
480
481
  is?: string
481
482
  }
482
483
 
484
+ type HTMLAttributeReferrerPolicy =
485
+ | ''
486
+ | 'no-referrer'
487
+ | 'no-referrer-when-downgrade'
488
+ | 'origin'
489
+ | 'origin-when-cross-origin'
490
+ | 'same-origin'
491
+ | 'strict-origin'
492
+ | 'strict-origin-when-cross-origin'
493
+ | 'unsafe-url'
494
+
483
495
  export interface AnchorHTMLAttributes extends HTMLAttributes {
484
496
  download?: any
485
497
  href?: string
@@ -489,7 +501,7 @@ export interface AnchorHTMLAttributes extends HTMLAttributes {
489
501
  rel?: string
490
502
  target?: string
491
503
  type?: string
492
- referrerpolicy?: string
504
+ referrerpolicy?: HTMLAttributeReferrerPolicy
493
505
  }
494
506
 
495
507
  export interface AreaHTMLAttributes extends HTMLAttributes {
@@ -499,6 +511,7 @@ export interface AreaHTMLAttributes extends HTMLAttributes {
499
511
  href?: string
500
512
  hreflang?: string
501
513
  media?: string
514
+ referrerpolicy?: HTMLAttributeReferrerPolicy
502
515
  rel?: string
503
516
  shape?: string
504
517
  target?: string
@@ -597,7 +610,7 @@ export interface IframeHTMLAttributes extends HTMLAttributes {
597
610
  marginheight?: Numberish
598
611
  marginwidth?: Numberish
599
612
  name?: string
600
- referrerpolicy?: string
613
+ referrerpolicy?: HTMLAttributeReferrerPolicy
601
614
  sandbox?: string
602
615
  scrolling?: string
603
616
  seamless?: Booleanish
@@ -611,6 +624,7 @@ export interface ImgHTMLAttributes extends HTMLAttributes {
611
624
  crossorigin?: 'anonymous' | 'use-credentials' | ''
612
625
  decoding?: 'async' | 'auto' | 'sync'
613
626
  height?: Numberish
627
+ referrerpolicy?: HTMLAttributeReferrerPolicy
614
628
  sizes?: string
615
629
  src?: string
616
630
  srcset?: string
@@ -685,6 +699,7 @@ export interface LinkHTMLAttributes extends HTMLAttributes {
685
699
  hreflang?: string
686
700
  integrity?: string
687
701
  media?: string
702
+ referrerpolicy?: HTMLAttributeReferrerPolicy
688
703
  rel?: string
689
704
  sizes?: string
690
705
  type?: string
@@ -785,6 +800,7 @@ export interface ScriptHTMLAttributes extends HTMLAttributes {
785
800
  defer?: Booleanish
786
801
  integrity?: string
787
802
  nomodule?: Booleanish
803
+ referrerpolicy?: HTMLAttributeReferrerPolicy
788
804
  nonce?: string
789
805
  src?: string
790
806
  type?: string
@@ -1472,7 +1488,9 @@ export interface Events {
1472
1488
  }
1473
1489
 
1474
1490
  type EventHandlers<E> = {
1475
- [K in keyof E]?: E[K] extends (...args: any) => any ? E[K] : (payload: E[K]) => void
1491
+ [K in keyof E]?: E[K] extends (...args: any) => any
1492
+ ? E[K]
1493
+ : (payload: E[K]) => void
1476
1494
  }
1477
1495
 
1478
1496
  // use namespace import to avoid collision with generated types which use