Skip to content

Instantly share code, notes, and snippets.

@themasch
Created December 13, 2016 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themasch/f10f1994612109a0bafbeab6859c5202 to your computer and use it in GitHub Desktop.
Save themasch/f10f1994612109a0bafbeab6859c5202 to your computer and use it in GitHub Desktop.
function createElement(definition) {
var attributes = definition.attributes
if (typeof definition.elementName !== 'string') {
var Class = definition.elementName
if (Class.getMetadata) {
var oMetadata = Class.getMetadata()
var sDefaultAggregation = oMetadata._sDefaultAggregation
if (typeof sDefaultAggregation === 'string') {
if (attributes[sDefaultAggregation] !== undefined && definition.children.length === 1) {
attributes[sDefaultAggregation].template = definition.children[0]
} else {
attributes[sDefaultAggregation] = definition.children
}
}
} // else create a sap.ui.core.HTML?
return new Class(attributes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment