|
| 1 | +import merge from "@ui5/webcomponents-utils/dist/sap/base/util/merge.js"; |
| 2 | + |
1 | 3 | import boot from "./boot.js";
|
2 | 4 | import { skipOriginalEvent } from "./config/NoConflict.js";
|
3 | 5 | import { getCompactSize } from "./config/CompactSize.js";
|
@@ -335,35 +337,22 @@ class UI5Element extends HTMLElement {
|
335 | 337 | }
|
336 | 338 |
|
337 | 339 | static getMetadata() {
|
338 |
| - let klass = this; // eslint-disable-line |
339 |
| - |
340 |
| - if (klass.hasOwnProperty("_metadata")) { // eslint-disable-line |
341 |
| - return klass._metadata; |
| 340 | + if (this.hasOwnProperty("_metadata")) { // eslint-disable-line |
| 341 | + return this._metadata; |
342 | 342 | }
|
343 | 343 |
|
344 |
| - const metadatas = [Object.assign(klass.metadata, {})]; |
| 344 | + const metadataObjects = [this.metadata]; |
| 345 | + let klass = this; // eslint-disable-line |
345 | 346 | while (klass !== UI5Element) {
|
346 | 347 | klass = Object.getPrototypeOf(klass);
|
347 |
| - metadatas.push(klass.metadata); |
| 348 | + metadataObjects.unshift(klass.metadata); |
348 | 349 | }
|
| 350 | + const mergedMetadata = merge({}, ...metadataObjects); |
349 | 351 |
|
350 |
| - const result = metadatas[0]; |
351 |
| - |
352 |
| - result.properties = this._mergeMetadataEntry(metadatas, "properties"); // merge properties |
353 |
| - result.slots = this._mergeMetadataEntry(metadatas, "slots"); // merge slots |
354 |
| - result.events = this._mergeMetadataEntry(metadatas, "events"); // merge events |
355 |
| - |
356 |
| - this._metadata = new UI5ElementMetadata(result); |
| 352 | + this._metadata = new UI5ElementMetadata(mergedMetadata); |
357 | 353 | return this._metadata;
|
358 | 354 | }
|
359 | 355 |
|
360 |
| - static _mergeMetadataEntry(metadatas, prop) { |
361 |
| - return metadatas.reverse().reduce((result, current) => { // eslint-disable-line |
362 |
| - Object.assign(result, current[prop] || {}); |
363 |
| - return result; |
364 |
| - }, {}); |
365 |
| - } |
366 |
| - |
367 | 356 | _attachChildPropertyUpdated(child, propData) {
|
368 | 357 | const listenFor = propData.listenFor,
|
369 | 358 | childMetadata = child.constructor.getMetadata(),
|
|
0 commit comments