MCPcopy
hub / github.com/rapi-doc/RapiDoc / attributeChangedCallback

Method attributeChangedCallback

src/rapidoc.js:576–658  ·  view source on GitHub ↗
(name, oldVal, newVal)

Source from the content-addressed store, hash-verified

574 }
575
576 attributeChangedCallback(name, oldVal, newVal) {
577 if (name === 'spec-url') {
578 if (oldVal !== newVal) {
579 // put it at the end of event-loop to load all the attributes
580 window.setTimeout(async () => {
581 await this.loadSpec(newVal);
582 // If goto-path is provided and no location-hash is present then try to scroll there
583 if (this.gotoPath && !window.location.hash) {
584 this.scrollToPath(this.gotoPath);
585 }
586 }, 0);
587 }
588 }
589 if (name === 'match-paths' || name === 'match-type' || name === 'remove-endpoints-with-badge-label-as') {
590 if (oldVal !== newVal) {
591 window.setTimeout(async () => {
592 await this.loadSpec(this.specUrl);
593 }, 0);
594 }
595 }
596 if (name === 'render-style') {
597 if (newVal === 'read') {
598 window.setTimeout(() => {
599 this.observeExpandedContent();
600 }, 100);
601 } else {
602 this.intersectionObserver.disconnect();
603 }
604 }
605 if (name === 'api-key-name' || name === 'api-key-location' || name === 'api-key-value') {
606 let updateSelectedApiKey = false;
607 let apiKeyName = '';
608 let apiKeyLocation = '';
609 let apiKeyValue = '';
610
611 if (name === 'api-key-name') {
612 if (this.getAttribute('api-key-location') && this.getAttribute('api-key-value')) {
613 apiKeyName = newVal;
614 apiKeyLocation = this.getAttribute('api-key-location');
615 apiKeyValue = this.getAttribute('api-key-value');
616 updateSelectedApiKey = true;
617 }
618 } else if (name === 'api-key-location') {
619 if (this.getAttribute('api-key-name') && this.getAttribute('api-key-value')) {
620 apiKeyLocation = newVal;
621 apiKeyName = this.getAttribute('api-key-name');
622 apiKeyValue = this.getAttribute('api-key-value');
623 updateSelectedApiKey = true;
624 }
625 } else if (name === 'api-key-value') {
626 if (this.getAttribute('api-key-name') && this.getAttribute('api-key-location')) {
627 apiKeyValue = newVal;
628 apiKeyLocation = this.getAttribute('api-key-location');
629 apiKeyName = this.getAttribute('api-key-name');
630 updateSelectedApiKey = true;
631 }
632 }
633

Callers

nothing calls this directly

Calls 6

loadSpecMethod · 0.95
scrollToPathMethod · 0.95
findMethod · 0.45
pushMethod · 0.45
requestUpdateMethod · 0.45

Tested by

no test coverage detected