@vue/runtime-dom 3.2.19 → 3.2.23

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.
@@ -112,16 +112,8 @@ function patchClass(el, value, isSVG) {
112
112
 
113
113
  function patchStyle(el, prev, next) {
114
114
  const style = el.style;
115
- const currentDisplay = style.display;
116
- if (!next) {
117
- el.removeAttribute('style');
118
- }
119
- else if (shared.isString(next)) {
120
- if (prev !== next) {
121
- style.cssText = next;
122
- }
123
- }
124
- else {
115
+ const isCssString = shared.isString(next);
116
+ if (next && !isCssString) {
125
117
  for (const key in next) {
126
118
  setStyle(style, key, next[key]);
127
119
  }
@@ -133,11 +125,22 @@ function patchStyle(el, prev, next) {
133
125
  }
134
126
  }
135
127
  }
136
- // indicates that the `display` of the element is controlled by `v-show`,
137
- // so we always keep the current `display` value regardless of the `style` value,
138
- // thus handing over control to `v-show`.
139
- if ('_vod' in el) {
140
- style.display = currentDisplay;
128
+ else {
129
+ const currentDisplay = style.display;
130
+ if (isCssString) {
131
+ if (prev !== next) {
132
+ style.cssText = next;
133
+ }
134
+ }
135
+ else if (prev) {
136
+ el.removeAttribute('style');
137
+ }
138
+ // indicates that the `display` of the element is controlled by `v-show`,
139
+ // so we always keep the current `display` value regardless of the `style`
140
+ // value, thus handing over control to `v-show`.
141
+ if ('_vod' in el) {
142
+ style.display = currentDisplay;
143
+ }
141
144
  }
142
145
  }
143
146
  const importantRE = /\s*!important$/;
@@ -220,12 +223,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
220
223
  el[key] = value == null ? '' : value;
221
224
  return;
222
225
  }
223
- if (key === 'value' && el.tagName !== 'PROGRESS') {
226
+ if (key === 'value' &&
227
+ el.tagName !== 'PROGRESS' &&
228
+ // custom elements may use _value internally
229
+ !el.tagName.includes('-')) {
224
230
  // store value as _value as well since
225
231
  // non-string values will be stringified.
226
232
  el._value = value;
227
233
  const newValue = value == null ? '' : value;
228
- if (el.value !== newValue) {
234
+ if (el.value !== newValue ||
235
+ // #4956: always set for OPTION elements because its value falls back to
236
+ // textContent if no value attribute is present. And setting .value for
237
+ // OPTION has no side effect
238
+ el.tagName === 'OPTION') {
229
239
  el.value = newValue;
230
240
  }
231
241
  if (value == null) {
@@ -483,22 +493,11 @@ class VueElement extends BaseClass {
483
493
  }
484
494
  this.attachShadow({ mode: 'open' });
485
495
  }
486
- // set initial attrs
487
- for (let i = 0; i < this.attributes.length; i++) {
488
- this._setAttr(this.attributes[i].name);
489
- }
490
- // watch future attr changes
491
- new MutationObserver(mutations => {
492
- for (const m of mutations) {
493
- this._setAttr(m.attributeName);
494
- }
495
- }).observe(this, { attributes: true });
496
496
  }
497
497
  connectedCallback() {
498
498
  this._connected = true;
499
499
  if (!this._instance) {
500
500
  this._resolveDef();
501
- this._update();
502
501
  }
503
502
  }
504
503
  disconnectedCallback() {
@@ -517,8 +516,18 @@ class VueElement extends BaseClass {
517
516
  if (this._resolved) {
518
517
  return;
519
518
  }
519
+ this._resolved = true;
520
+ // set initial attrs
521
+ for (let i = 0; i < this.attributes.length; i++) {
522
+ this._setAttr(this.attributes[i].name);
523
+ }
524
+ // watch future attr changes
525
+ new MutationObserver(mutations => {
526
+ for (const m of mutations) {
527
+ this._setAttr(m.attributeName);
528
+ }
529
+ }).observe(this, { attributes: true });
520
530
  const resolve = (def) => {
521
- this._resolved = true;
522
531
  const { props, styles } = def;
523
532
  const hasOptions = !shared.isArray(props);
524
533
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -533,14 +542,11 @@ class VueElement extends BaseClass {
533
542
  }
534
543
  }
535
544
  }
536
- if (numberProps) {
537
- this._numberProps = numberProps;
538
- this._update();
539
- }
545
+ this._numberProps = numberProps;
540
546
  // check if there are props set pre-upgrade or connect
541
547
  for (const key of Object.keys(this)) {
542
548
  if (key[0] !== '_') {
543
- this._setProp(key, this[key]);
549
+ this._setProp(key, this[key], true, false);
544
550
  }
545
551
  }
546
552
  // defining getter/setters on prototype
@@ -554,7 +560,10 @@ class VueElement extends BaseClass {
554
560
  }
555
561
  });
556
562
  }
563
+ // apply CSS
557
564
  this._applyStyles(styles);
565
+ // initial render
566
+ this._update();
558
567
  };
559
568
  const asyncDef = this._def.__asyncLoader;
560
569
  if (asyncDef) {
@@ -580,10 +589,10 @@ class VueElement extends BaseClass {
580
589
  /**
581
590
  * @internal
582
591
  */
583
- _setProp(key, val, shouldReflect = true) {
592
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
584
593
  if (val !== this._props[key]) {
585
594
  this._props[key] = val;
586
- if (this._instance) {
595
+ if (shouldUpdate && this._instance) {
587
596
  this._update();
588
597
  }
589
598
  // reflect
@@ -112,16 +112,8 @@ function patchClass(el, value, isSVG) {
112
112
 
113
113
  function patchStyle(el, prev, next) {
114
114
  const style = el.style;
115
- const currentDisplay = style.display;
116
- if (!next) {
117
- el.removeAttribute('style');
118
- }
119
- else if (shared.isString(next)) {
120
- if (prev !== next) {
121
- style.cssText = next;
122
- }
123
- }
124
- else {
115
+ const isCssString = shared.isString(next);
116
+ if (next && !isCssString) {
125
117
  for (const key in next) {
126
118
  setStyle(style, key, next[key]);
127
119
  }
@@ -133,11 +125,22 @@ function patchStyle(el, prev, next) {
133
125
  }
134
126
  }
135
127
  }
136
- // indicates that the `display` of the element is controlled by `v-show`,
137
- // so we always keep the current `display` value regardless of the `style` value,
138
- // thus handing over control to `v-show`.
139
- if ('_vod' in el) {
140
- style.display = currentDisplay;
128
+ else {
129
+ const currentDisplay = style.display;
130
+ if (isCssString) {
131
+ if (prev !== next) {
132
+ style.cssText = next;
133
+ }
134
+ }
135
+ else if (prev) {
136
+ el.removeAttribute('style');
137
+ }
138
+ // indicates that the `display` of the element is controlled by `v-show`,
139
+ // so we always keep the current `display` value regardless of the `style`
140
+ // value, thus handing over control to `v-show`.
141
+ if ('_vod' in el) {
142
+ style.display = currentDisplay;
143
+ }
141
144
  }
142
145
  }
143
146
  const importantRE = /\s*!important$/;
@@ -220,12 +223,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
220
223
  el[key] = value == null ? '' : value;
221
224
  return;
222
225
  }
223
- if (key === 'value' && el.tagName !== 'PROGRESS') {
226
+ if (key === 'value' &&
227
+ el.tagName !== 'PROGRESS' &&
228
+ // custom elements may use _value internally
229
+ !el.tagName.includes('-')) {
224
230
  // store value as _value as well since
225
231
  // non-string values will be stringified.
226
232
  el._value = value;
227
233
  const newValue = value == null ? '' : value;
228
- if (el.value !== newValue) {
234
+ if (el.value !== newValue ||
235
+ // #4956: always set for OPTION elements because its value falls back to
236
+ // textContent if no value attribute is present. And setting .value for
237
+ // OPTION has no side effect
238
+ el.tagName === 'OPTION') {
229
239
  el.value = newValue;
230
240
  }
231
241
  if (value == null) {
@@ -475,22 +485,11 @@ class VueElement extends BaseClass {
475
485
  else {
476
486
  this.attachShadow({ mode: 'open' });
477
487
  }
478
- // set initial attrs
479
- for (let i = 0; i < this.attributes.length; i++) {
480
- this._setAttr(this.attributes[i].name);
481
- }
482
- // watch future attr changes
483
- new MutationObserver(mutations => {
484
- for (const m of mutations) {
485
- this._setAttr(m.attributeName);
486
- }
487
- }).observe(this, { attributes: true });
488
488
  }
489
489
  connectedCallback() {
490
490
  this._connected = true;
491
491
  if (!this._instance) {
492
492
  this._resolveDef();
493
- this._update();
494
493
  }
495
494
  }
496
495
  disconnectedCallback() {
@@ -509,8 +508,18 @@ class VueElement extends BaseClass {
509
508
  if (this._resolved) {
510
509
  return;
511
510
  }
511
+ this._resolved = true;
512
+ // set initial attrs
513
+ for (let i = 0; i < this.attributes.length; i++) {
514
+ this._setAttr(this.attributes[i].name);
515
+ }
516
+ // watch future attr changes
517
+ new MutationObserver(mutations => {
518
+ for (const m of mutations) {
519
+ this._setAttr(m.attributeName);
520
+ }
521
+ }).observe(this, { attributes: true });
512
522
  const resolve = (def) => {
513
- this._resolved = true;
514
523
  const { props, styles } = def;
515
524
  const hasOptions = !shared.isArray(props);
516
525
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -525,14 +534,11 @@ class VueElement extends BaseClass {
525
534
  }
526
535
  }
527
536
  }
528
- if (numberProps) {
529
- this._numberProps = numberProps;
530
- this._update();
531
- }
537
+ this._numberProps = numberProps;
532
538
  // check if there are props set pre-upgrade or connect
533
539
  for (const key of Object.keys(this)) {
534
540
  if (key[0] !== '_') {
535
- this._setProp(key, this[key]);
541
+ this._setProp(key, this[key], true, false);
536
542
  }
537
543
  }
538
544
  // defining getter/setters on prototype
@@ -546,7 +552,10 @@ class VueElement extends BaseClass {
546
552
  }
547
553
  });
548
554
  }
555
+ // apply CSS
549
556
  this._applyStyles(styles);
557
+ // initial render
558
+ this._update();
550
559
  };
551
560
  const asyncDef = this._def.__asyncLoader;
552
561
  if (asyncDef) {
@@ -572,10 +581,10 @@ class VueElement extends BaseClass {
572
581
  /**
573
582
  * @internal
574
583
  */
575
- _setProp(key, val, shouldReflect = true) {
584
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
576
585
  if (val !== this._props[key]) {
577
586
  this._props[key] = val;
578
- if (this._instance) {
587
+ if (shouldUpdate && this._instance) {
579
588
  this._update();
580
589
  }
581
590
  // reflect
@@ -197,7 +197,9 @@ export { }
197
197
  import { VNode } from '@vue/runtime-core'
198
198
  import * as CSS from 'csstype'
199
199
 
200
- export interface CSSProperties extends CSS.Properties<string | number>, CSS.PropertiesHyphen<string | number> {
200
+ export interface CSSProperties
201
+ extends CSS.Properties<string | number>,
202
+ CSS.PropertiesHyphen<string | number> {
201
203
  /**
202
204
  * The index signature was removed to enable closed typing for style
203
205
  * using CSSType. You're able to use type assertion or module augmentation