@vaadin/component-base 23.3.6 → 23.3.7

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": "23.3.6",
3
+ "version": "23.3.7",
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": "3ea0e9875f51cca9c4f78cf731fd8009c5a45ddb"
45
+ "gitHead": "9689f8650a9170b38c0ee691b9603ffb550e04ad"
46
46
  }
@@ -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 '23.3.6';
42
+ return '23.3.7';
43
43
  }
44
44
 
45
45
  /** @protected */
@@ -23,6 +23,7 @@ const DEFAULT_PHYSICAL_COUNT = 3;
23
23
  * If something in the scrolling engine needs to be changed
24
24
  * for the virtualizer's purposes, override a function
25
25
  * in virtualizer-iron-list-adapter.js instead of changing it here.
26
+ * If a function on this file is no longer needed, the code can be safely deleted.
26
27
  *
27
28
  * This will allow us to keep the iron-list code here as close to
28
29
  * the original as possible.
@@ -560,39 +561,6 @@ export const ironList = {
560
561
  return this._virtualStart + (this._physicalCount - this._physicalStart) + pidx;
561
562
  },
562
563
 
563
- /**
564
- * Updates the height for a given set of items.
565
- *
566
- * @param {!Array<number>=} itemSet
567
- */
568
- _updateMetrics(itemSet) {
569
- // Make sure we distributed all the physical items
570
- // so we can measure them.
571
- flush();
572
-
573
- let newPhysicalSize = 0;
574
- let oldPhysicalSize = 0;
575
- const prevAvgCount = this._physicalAverageCount;
576
- const prevPhysicalAvg = this._physicalAverage;
577
-
578
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
579
- this._iterateItems((pidx, vidx) => {
580
- oldPhysicalSize += this._physicalSizes[pidx];
581
- this._physicalSizes[pidx] = this._physicalItems[pidx].offsetHeight;
582
- newPhysicalSize += this._physicalSizes[pidx];
583
- this._physicalAverageCount += this._physicalSizes[pidx] ? 1 : 0;
584
- }, itemSet);
585
-
586
- this._physicalSize = this._physicalSize + newPhysicalSize - oldPhysicalSize;
587
-
588
- // Update the average if it measured something.
589
- if (this._physicalAverageCount !== prevAvgCount) {
590
- this._physicalAverage = Math.round(
591
- (prevPhysicalAvg * prevAvgCount + newPhysicalSize) / this._physicalAverageCount,
592
- );
593
- }
594
- },
595
-
596
564
  /**
597
565
  * Updates the position of the physical items.
598
566
  */
@@ -141,6 +141,56 @@ export class IronListAdapter {
141
141
  });
142
142
  }
143
143
 
144
+ /**
145
+ * Updates the height for a given set of items.
146
+ *
147
+ * @param {!Array<number>=} itemSet
148
+ */
149
+ _updateMetrics(itemSet) {
150
+ // Make sure we distributed all the physical items
151
+ // so we can measure them.
152
+ flush();
153
+
154
+ let newPhysicalSize = 0;
155
+ let oldPhysicalSize = 0;
156
+ const prevAvgCount = this._physicalAverageCount;
157
+ const prevPhysicalAvg = this._physicalAverage;
158
+
159
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
160
+ this._iterateItems((pidx, vidx) => {
161
+ oldPhysicalSize += this._physicalSizes[pidx];
162
+ this._physicalSizes[pidx] = Math.ceil(this.__getBorderBoxHeight(this._physicalItems[pidx]));
163
+ newPhysicalSize += this._physicalSizes[pidx];
164
+ this._physicalAverageCount += this._physicalSizes[pidx] ? 1 : 0;
165
+ }, itemSet);
166
+
167
+ this._physicalSize = this._physicalSize + newPhysicalSize - oldPhysicalSize;
168
+
169
+ // Update the average if it measured something.
170
+ if (this._physicalAverageCount !== prevAvgCount) {
171
+ this._physicalAverage = Math.round(
172
+ (prevPhysicalAvg * prevAvgCount + newPhysicalSize) / this._physicalAverageCount,
173
+ );
174
+ }
175
+ }
176
+
177
+ __getBorderBoxHeight(el) {
178
+ const style = getComputedStyle(el);
179
+
180
+ const itemHeight = parseFloat(style.height) || 0;
181
+
182
+ if (style.boxSizing === 'border-box') {
183
+ return itemHeight;
184
+ }
185
+
186
+ const paddingBottom = parseFloat(style.paddingBottom) || 0;
187
+ const paddingTop = parseFloat(style.paddingTop) || 0;
188
+ const borderBottomWidth = parseFloat(style.borderBottomWidth) || 0;
189
+ const borderTopWidth = parseFloat(style.borderTopWidth) || 0;
190
+
191
+ return itemHeight + paddingBottom + paddingTop + borderBottomWidth + borderTopWidth;
192
+ }
193
+
144
194
  __updateElement(el, index, forceSameIndexUpdates) {
145
195
  // Clean up temporary placeholder sizing
146
196
  if (el.style.paddingTop) {