MCPcopy Index your code
hub / github.com/ampproject/amphtml / rerender_

Method rerender_

src/preact/base-element.js:611–769  ·  view source on GitHub ↗

@private

()

Source from the content-addressed store, hash-verified

609
610 /** @private */
611 rerender_() {
612 // If the component unmounted before the scheduled render runs, exit
613 // early.
614 if (!this.mounted_) {
615 return;
616 }
617
618 const Ctor = /** @type {typeof PreactBaseElement} */ (
619 /** @type {?} */ (this.constructor)
620 );
621 const {detached: isDetached, usesShadowDom: isShadow} = Ctor;
622 const lightDomTag = isShadow ? null : Ctor.lightDomTag;
623
624 if (!this.container_) {
625 const doc = this.win.document;
626 if (isShadow) {
627 devAssert(
628 !isDetached,
629 'The AMP element cannot be rendered in detached mode ' +
630 'when "props" are configured with "children" property.'
631 );
632 // Check if there's a pre-constructed shadow DOM.
633 let {shadowRoot} = this.element;
634 let container = shadowRoot && childElementByTag(shadowRoot, 'c');
635 if (container) {
636 this.hydrationPending_ = true;
637 } else {
638 // Create new shadow root.
639 shadowRoot = this.element.attachShadow({
640 mode: 'open',
641 delegatesFocus: Ctor.delegatesFocus,
642 });
643
644 // The pre-constructed shadow root is required to have the stylesheet
645 // inline. Thus, only the new shadow roots share the stylesheets.
646 const {shadowCss} = Ctor;
647 if (shadowCss) {
648 installShadowStyle(shadowRoot, this.element.tagName, shadowCss);
649 }
650
651 // Create container.
652 // The pre-constructed shadow root is required to have this container.
653 container = createElementWithAttributes(
654 doc,
655 'c',
656 SHADOW_CONTAINER_ATTRS
657 );
658 shadowRoot.appendChild(container);
659
660 // Create a slot for internal service elements i.e. "i-amphtml-sizer".
661 // The pre-constructed shadow root is required to have this slot.
662 const serviceSlot = createElementWithAttributes(
663 doc,
664 'slot',
665 SERVICE_SLOT_ATTRS
666 );
667 shadowRoot.appendChild(serviceSlot);
668 this.getPlaceholder?.()?.setAttribute('slot', SERVICE_SLOT_NAME);

Callers 1

constructorMethod · 0.95

Calls 15

isReadyMethod · 0.95
devAssertFunction · 0.90
childElementByTagFunction · 0.90
installShadowStyleFunction · 0.90
setParentFunction · 0.90
addGroupFunction · 0.90
setGroupPropFunction · 0.90
childElementByAttrFunction · 0.90
applyFillContentFunction · 0.90
collectPropsFunction · 0.90

Tested by

no test coverage detected