MCPcopy Index your code
hub / github.com/rapi-doc/RapiDoc / connectedCallback

Method connectedCallback

src/rapidoc.js:425–542  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

423
424 // Startup
425 connectedCallback() {
426 super.connectedCallback();
427 const parent = this.parentElement;
428 if (parent) {
429 if (parent.offsetWidth === 0 && parent.style.width === '') {
430 parent.style.width = '100vw';
431 }
432 if (parent.offsetHeight === 0 && parent.style.height === '') {
433 parent.style.height = '100vh';
434 }
435 if (parent.tagName === 'BODY') {
436 if (!parent.style.marginTop) { parent.style.marginTop = '0'; }
437 if (!parent.style.marginRight) { parent.style.marginRight = '0'; }
438 if (!parent.style.marginBottom) { parent.style.marginBottom = '0'; }
439 if (!parent.style.marginLeft) { parent.style.marginLeft = '0'; }
440 }
441 }
442
443 if (this.loadFonts !== 'false') {
444 const fontDescriptor = {
445 family: 'Open Sans',
446 style: 'normal',
447 weight: '300',
448 unicodeRange: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
449 };
450 const fontWeight300 = new FontFace(
451 'Open Sans',
452 "url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UN_r8OUuhpKKSTjw.woff2) format('woff2')",
453 fontDescriptor,
454 );
455 fontDescriptor.weight = '600';
456 const fontWeight600 = new FontFace(
457 'Open Sans',
458 "url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UNirkOUuhpKKSTjw.woff2) format('woff2')",
459 fontDescriptor,
460 );
461 fontWeight300.load().then((font) => { document.fonts.add(font); });
462 fontWeight600.load().then((font) => { document.fonts.add(font); });
463 }
464
465 if (!this.layout || !'row, column,'.includes(`${this.layout},`)) { this.layout = 'row'; }
466 if (!this.renderStyle || !'read, view, focused,'.includes(`${this.renderStyle},`)) { this.renderStyle = 'focused'; }
467 if (!this.schemaStyle || !'tree, table,'.includes(`${this.schemaStyle},`)) { this.schemaStyle = 'tree'; }
468 if (!this.theme || !'light, dark,'.includes(`${this.theme},`)) {
469 this.theme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) ? 'light' : 'dark';
470 }
471 if (!this.defaultSchemaTab || !'example, schema, model,'.includes(`${this.defaultSchemaTab},`)) {
472 this.defaultSchemaTab = 'example';
473 } else if (this.defaultSchemaTab === 'model') {
474 this.defaultSchemaTab = 'schema';
475 }
476 if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
477 if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
478
479 if (!this.schemaHideReadOnly || !'default, never,'.includes(`${this.schemaHideReadOnly},`)) { this.schemaHideReadOnly = 'default'; }
480 if (!this.schemaHideWriteOnly || !'default, never,'.includes(`${this.schemaHideWriteOnly},`)) { this.schemaHideWriteOnly = 'default'; }
481
482 if (!this.fillRequestFieldsWithExample || !'true, false,'.includes(`${this.fillRequestFieldsWithExample},`)) { this.fillRequestFieldsWithExample = 'true'; }

Callers

nothing calls this directly

Calls 5

scrollToPathMethod · 0.95
getElementIDFromURLMethod · 0.95
thenMethod · 0.45
addMethod · 0.45
includesMethod · 0.45

Tested by

no test coverage detected