@vaadin/component-base 24.0.0-alpha6 → 24.0.0-alpha7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "24.0.0-alpha6",
3
+ "version": "24.0.0-alpha7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,5 +42,5 @@
42
42
  "@vaadin/testing-helpers": "^0.3.2",
43
43
  "sinon": "^13.0.2"
44
44
  },
45
- "gitHead": "0004ac92b6e5f415b5fa949e0582d1d11e527b1f"
45
+ "gitHead": "aeb4535336813636736759e0a5de148b26bfc3b6"
46
46
  }
@@ -15,14 +15,14 @@ import { DirMixin } from './dir-mixin.js';
15
15
  // for buttons that are based on `[role=button]` e.g vaadin-button.
16
16
  setCancelSyntheticClickEvents(false);
17
17
 
18
- window.Vaadin = window.Vaadin || {};
18
+ window.Vaadin ||= {};
19
19
 
20
20
  /**
21
21
  * Array of Vaadin custom element classes that have been finalized.
22
22
  */
23
- window.Vaadin.registrations = window.Vaadin.registrations || [];
23
+ window.Vaadin.registrations ||= [];
24
24
 
25
- window.Vaadin.developmentModeCallback = window.Vaadin.developmentModeCallback || {};
25
+ window.Vaadin.developmentModeCallback ||= {};
26
26
 
27
27
  window.Vaadin.developmentModeCallback['vaadin-usage-statistics'] = function () {
28
28
  usageStatistics();
@@ -39,7 +39,7 @@ const registered = new Set();
39
39
  export const ElementMixin = (superClass) =>
40
40
  class VaadinElementMixin extends DirMixin(superClass) {
41
41
  static get version() {
42
- return '24.0.0-alpha6';
42
+ return '24.0.0-alpha7';
43
43
  }
44
44
 
45
45
  /** @protected */
@@ -491,9 +491,9 @@ export const ironList = {
491
491
  this._physicalIndexForKey = {};
492
492
  this._firstVisibleIndexVal = null;
493
493
  this._lastVisibleIndexVal = null;
494
- this._physicalCount = this._physicalCount || 0;
495
- this._physicalItems = this._physicalItems || [];
496
- this._physicalSizes = this._physicalSizes || [];
494
+ this._physicalCount ||= 0;
495
+ this._physicalItems ||= [];
496
+ this._physicalSizes ||= [];
497
497
  this._physicalStart = 0;
498
498
  if (this._scrollTop > this._scrollOffset) {
499
499
  this._resetScrollPosition(0);
@@ -639,8 +639,8 @@ export const ironList = {
639
639
  this._physicalBottom +
640
640
  Math.max(this._virtualCount - this._physicalCount - this._virtualStart, 0) * this._physicalAverage;
641
641
 
642
- forceUpdate = forceUpdate || this._scrollHeight === 0;
643
- forceUpdate = forceUpdate || this._scrollPosition >= this._estScrollHeight - this._physicalSize;
642
+ forceUpdate ||= this._scrollHeight === 0;
643
+ forceUpdate ||= this._scrollPosition >= this._estScrollHeight - this._physicalSize;
644
644
  // Amortize height adjustment, so it won't trigger large repaints too often.
645
645
  if (forceUpdate || Math.abs(this._estScrollHeight - this._scrollHeight) >= this._viewportHeight) {
646
646
  this.$.items.style.height = `${this._estScrollHeight}px`;
@@ -740,7 +740,7 @@ export const ironList = {
740
740
  },
741
741
 
742
742
  _debounce(name, cb, asyncModule) {
743
- this._debouncers = this._debouncers || {};
743
+ this._debouncers ||= {};
744
744
  this._debouncers[name] = Debouncer.debounce(this._debouncers[name], asyncModule, cb.bind(this));
745
745
  enqueueDebouncer(this._debouncers[name]);
746
746
  },
@@ -92,7 +92,7 @@ export class OverflowController {
92
92
  overflow += ' top';
93
93
  }
94
94
 
95
- if (target.scrollTop < target.scrollHeight - target.clientHeight) {
95
+ if (Math.ceil(target.scrollTop) < Math.ceil(target.scrollHeight - target.clientHeight)) {
96
96
  overflow += ' bottom';
97
97
  }
98
98
 
@@ -101,7 +101,7 @@ export class OverflowController {
101
101
  overflow += ' start';
102
102
  }
103
103
 
104
- if (scrollLeft < target.scrollWidth - target.clientWidth) {
104
+ if (Math.ceil(scrollLeft) < Math.ceil(target.scrollWidth - target.clientWidth)) {
105
105
  overflow += ' end';
106
106
  }
107
107
 
@@ -10,7 +10,7 @@ const caseMap = {};
10
10
  const CAMEL_TO_DASH = /([A-Z])/g;
11
11
 
12
12
  function camelToDash(camel) {
13
- caseMap[camel] = caseMap[camel] || camel.replace(CAMEL_TO_DASH, '-$1').toLowerCase();
13
+ caseMap[camel] ||= camel.replace(CAMEL_TO_DASH, '-$1').toLowerCase();
14
14
  return caseMap[camel];
15
15
  }
16
16
 
@@ -169,7 +169,7 @@ const PolylitMixinImplementation = (superclass) => {
169
169
  firstUpdated() {
170
170
  super.firstUpdated();
171
171
 
172
- this.$ = this.$ || {};
172
+ this.$ ||= {};
173
173
  this.shadowRoot.querySelectorAll('[id]').forEach((node) => {
174
174
  this.$[node.id] = node;
175
175
  });
@@ -14,12 +14,12 @@ export class SlotController extends EventTarget {
14
14
  /**
15
15
  * Ensure that every instance has unique ID.
16
16
  *
17
- * @param {string} slotName
18
17
  * @param {HTMLElement} host
18
+ * @param {string} slotName
19
19
  * @return {string}
20
20
  * @protected
21
21
  */
22
- static generateId(slotName, host) {
22
+ static generateId(host, slotName) {
23
23
  const prefix = slotName || 'default';
24
24
  return `${prefix}-${host.localName}-${generateUniqueId()}`;
25
25
  }
@@ -42,7 +42,7 @@ export class SlotController extends EventTarget {
42
42
 
43
43
  // Only generate the default ID if requested by the controller.
44
44
  if (useUniqueId) {
45
- this.defaultId = SlotController.generateId(slotName, host);
45
+ this.defaultId = this.constructor.generateId(host, slotName);
46
46
  }
47
47
  }
48
48
 
@@ -107,7 +107,7 @@ export class SlotObserveController extends SlotController {
107
107
  if (mutation.type === 'attributes') {
108
108
  // We use attributeFilter to only observe ID mutation,
109
109
  // no need to check for attribute name separately.
110
- if (isCurrentNodeMutation && target.id !== this.defaultId) {
110
+ if (isCurrentNodeMutation) {
111
111
  this.__updateNodeId(target);
112
112
  }
113
113
  } else if (isCurrentNodeMutation || target.parentElement === this.node) {
@@ -141,8 +141,7 @@ export class SlotObserveController extends SlotController {
141
141
  }
142
142
 
143
143
  return (
144
- node.children.length > 0 ||
145
- (node.nodeType === Node.ELEMENT_NODE && customElements.get(node.localName)) ||
144
+ (node.nodeType === Node.ELEMENT_NODE && (customElements.get(node.localName) || node.children.length > 0)) ||
146
145
  (node.textContent && node.textContent.trim() !== '')
147
146
  );
148
147
  }
@@ -168,7 +167,9 @@ export class SlotObserveController extends SlotController {
168
167
  * @private
169
168
  */
170
169
  __updateNodeId(node) {
171
- if (node.nodeType === Node.ELEMENT_NODE && !node.id) {
170
+ // When in multiple mode, only set ID attribute on the element in default slot.
171
+ const isFirstNode = !this.nodes || node === this.nodes[0];
172
+ if (node.nodeType === Node.ELEMENT_NODE && isFirstNode && !node.id) {
172
173
  node.id = this.defaultId;
173
174
  }
174
175
  }
@@ -376,7 +376,7 @@ export class IronListAdapter {
376
376
  deltaY *= this._scrollPageHeight;
377
377
  }
378
378
 
379
- this._deltaYAcc = this._deltaYAcc || 0;
379
+ this._deltaYAcc ||= 0;
380
380
 
381
381
  if (this._wheelAnimationFrame) {
382
382
  // Accumulate wheel delta while a frame is being processed