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

Method onBeforeRendering

packages/main/src/Icon.ts:311–376  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

309 }
310
311 async onBeforeRendering() {
312 if (this.fontIcon.length) {
313 // Font-based icon via slot — skip registry, accessibility is app's responsibility
314 if (!this.accessibleName) {
315 this.effectiveAccessibleName = undefined;
316 } else {
317 this.effectiveAccessibleName = this.accessibleName;
318 }
319 return;
320 }
321
322 const name = this.name;
323 if (!name) {
324 return;
325 }
326
327 let iconData: typeof ICON_NOT_FOUND | IconData | UnsafeIconData | undefined = getIconDataSync(name);
328 if (!iconData) {
329 iconData = await getIconData(name);
330 }
331
332 if (!iconData) {
333 this.invalid = true;
334 /* eslint-disable-next-line */
335 return console.warn(`Required icon is not registered. Invalid icon name: ${this.name}`);
336 }
337
338 if (iconData === ICON_NOT_FOUND) {
339 this.invalid = true;
340 /* eslint-disable-next-line */
341 return console.warn(`Required icon is not registered. You can either import the icon as a module in order to use it e.g. "@ui5/webcomponents-icons/dist/${name.replace("sap-icon://", "")}.js", or setup a JSON build step and import "@ui5/webcomponents-icons/dist/AllIcons.js".`);
342 }
343
344 this.viewBox = iconData.viewBox || "0 0 512 512";
345
346 if ("customTemplate" in iconData && iconData.customTemplate) {
347 this.customTemplate = executeTemplate(iconData.customTemplate, this);
348 }
349
350 if ("customTemplateAsString" in iconData) {
351 this.customTemplateAsString = iconData.customTemplateAsString;
352 }
353
354 // in case a new valid name is set, show the icon
355 this.invalid = false;
356 if ("pathData" in iconData && iconData.pathData) {
357 this.pathData = Array.isArray(iconData.pathData) ? iconData.pathData : [iconData.pathData];
358 }
359
360 this.accData = iconData.accData;
361 this.ltr = iconData.ltr;
362 this.packageName = iconData.packageName;
363
364 if (this.accessibleName) {
365 this.effectiveAccessibleName = this.accessibleName;
366 } else if (this.accData) {
367 if (this.packageName) {
368 const i18nBundle = await getI18nBundle(this.packageName);

Callers

nothing calls this directly

Calls 5

getIconDataSyncFunction · 0.85
getIconDataFunction · 0.85
executeTemplateFunction · 0.85
getI18nBundleFunction · 0.85
getTextMethod · 0.80

Tested by

no test coverage detected