Skip to content

Commit

Permalink
chore: add events info to UI5ElementMetadata (#837)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilhan007 authored Oct 10, 2019
1 parent 21ec559 commit e163d17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/base/src/UI5Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,22 +321,21 @@ class UI5Element extends HTMLElement {

const result = metadatas[0];

// merge properties
result.properties = metadatas.reverse().reduce((allProperties, current) => { // eslint-disable-line
Object.assign(allProperties, current.properties || {});
return allProperties;
}, {});

// merge slots
result.slots = metadatas.reverse().reduce((allSlots, current) => { // eslint-disable-line
Object.assign(allSlots, current.slots || {});
return allSlots;
}, {});
result.properties = this._mergeMetadataEntry(metadatas, "properties"); // merge properties
result.slots = this._mergeMetadataEntry(metadatas, "slots"); // merge slots
result.events = this._mergeMetadataEntry(metadatas, "events"); // merge events

this._metadata = new UI5ElementMetadata(result);
return this._metadata;
}

static _mergeMetadataEntry(metadatas, prop) {
return metadatas.reverse().reduce((result, current) => { // eslint-disable-line
Object.assign(result, current[prop] || {});
return result;
}, {});
}

_attachChildPropertyUpdated(child, propData) {
const listenFor = propData.listenFor,
childMetadata = child.constructor.getMetadata(),
Expand Down
4 changes: 4 additions & 0 deletions packages/base/src/UI5ElementMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class UI5ElementMetadata {
return this.metadata.properties || {};
}

getEvents() {
return this.metadata.events || {};
}

static validatePropertyValue(value, propData) {
const isMultiple = propData.multiple;
if (isMultiple) {
Expand Down

0 comments on commit e163d17

Please sign in to comment.