templateTitle; // FIXME: Insufficient - missing check for template args, indirect dependencies $tplNodes = DOMCompat::querySelectorAll( $root, '[typeof~="mw:Transclusion"]' ); foreach ( $tplNodes as $tplNode ) { $dataMw = DOMDataUtils::getDataMW( $tplNode ); $ti = $dataMw->parts[0] ?? null; if ( !is_string( $ti ) && $ti->href === $tplTitle ) { $dp = DOMDataUtils::getDataParsoid( $tplNode ); $wt = $dp->dsr->substr( $selparData->revText ); $opts = [ 'pipelineType' => 'selective-update-fragment-wikitext-to-dom', 'sol' => false, // FIXME: Not strictly correct 'srcText' => $selparData->revText, 'pipelineOpts' => [], 'srcOffsets' => $dp->dsr, ]; // Process template string in new pipeline $frag = PipelineUtils::processContentInPipeline( $env, $options['frame'], $wt, $opts ); // Pull out only the transclusion marked portion of $frag & strip p-wrapper $newContent = $frag->firstChild; if ( DOMCompat::nodeName( $tplNode ) !== 'p' && DOMCompat::nodeName( $newContent ) === 'p' ) { $newContent = $newContent->firstChild; } DOMDataUtils::getDataParsoid( $newContent )->dsr = $dp->dsr; // Delete template from DOM + add new content to DOM // Note that $tplNode and $frag may have more than one child in the general case $tplParent = $tplNode->parentNode; $about = DOMCompat::getAttribute( $tplNode, 'about' ); do { $next = $tplNode->nextSibling; $tplParent->removeChild( $tplNode ); $tplNode = $next; } while ( $tplNode instanceof Element && DOMCompat::getAttribute( $tplNode, 'about' ) === $about ); DOMUtils::migrateChildren( $newContent->parentNode, $tplParent, $tplNode ); } } } }