MCPcopy Create free account
hub / github.com/UI5/webcomponents / define

Function define

packages/base/src/UI5Element.ts:1414–1445  ·  view source on GitHub ↗

* Registers a UI5 Web Component in the browser window object * @public

()

Source from the content-addressed store, hash-verified

1412 * @public
1413 */
1414 static define(): typeof UI5Element {
1415 const defineSequence = async () => {
1416 await boot(); // boot must finish first, because it initializes configuration
1417 const result = await Promise.all([
1418 this.fetchI18nBundles(), // uses configuration
1419 this.fetchCLDR(),
1420 this.onDefine(),
1421 ]);
1422 const [i18nBundles] = result;
1423 Object.entries(this.getMetadata().getI18n()).forEach((pair, index) => {
1424 const bundleName = pair[1].bundleName;
1425 this.i18nBundleStorage[bundleName] = i18nBundles[index];
1426 });
1427 this.asyncFinished = true;
1428 };
1429 this._definePromise = defineSequence();
1430
1431 const tag = this.getMetadata().getTag();
1432
1433 const definedLocally = isTagRegistered(tag);
1434 const definedGlobally = customElements.get(tag);
1435
1436 if (definedGlobally && !definedLocally) {
1437 recordTagRegistrationFailure(tag);
1438 } else if (!definedGlobally) {
1439 this._generateAccessors();
1440 registerTag(tag);
1441 customElements.define(tag, this as unknown as CustomElementConstructor);
1442 }
1443
1444 return this;
1445 }
1446
1447 /**
1448 * Returns an instance of UI5ElementMetadata.js representing this UI5 Web Component's full metadata (its and its parents')

Callers

nothing calls this directly

Calls 7

defineSequenceFunction · 0.85
isTagRegisteredFunction · 0.85
registerTagFunction · 0.85
getTagMethod · 0.80
getMetadataMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…