parsoid because it has a custom clone method unset( $cloneableData['parsoid'] ); // Don't clone storedId because it doesn't need it unset( $cloneableData['storedId'] ); // Deep clone everything else $cloneableData = Utils::clone( $cloneableData ); $nd = clone $this; if ( $nd->parsoid ) { $nd->parsoid = $nd->parsoid->clone(); } // Avoid cloning sealed DOMFragments that may occur in expanded attributes if ( $nd->mw && $stripSealedFragments && is_array( $nd->mw->attribs ) ) { foreach ( $nd->mw->attribs as $attr ) { // Look for DOMFragments in both key and value of DataMwAttrib foreach ( [ 'key', 'value' ] as $part ) { if ( isset( $attr->$part['html'] ) && str_contains( $attr->$part['html'], 'mw:DOMFragment/sealed' ) ) { $doc = DOMUtils::parseHTML( $attr->$part['html'] ); DOMUtils::visitDOM( $doc, static function ( Node $node ) { if ( DOMUtils::matchTypeOf( $node, '#^mw:DOMFragment/sealed/\w+$#D' ) ) { DOMCompat::getParentElement( $node )->removeChild( $node ); } } ); $attr->$part['html'] = DOMCompat::getInnerHTML( DOMCompat::getBody( $doc ) ); } } } } foreach ( $cloneableData as $key => $value ) { $nd->$key = $value; } return $nd; } }