Don't add custom attributes in unwrapParsoidSections()

This code was unnecessarily copied from VE. It's not needed for
anything in this extension, and it causes the headings to be treated
as modified by selser, which in turn causes dirty diffs.

Depends-On: Ib5ed98e2c98de50deb94f8ea46e9122e7e836604
Bug: T328268
Change-Id: Ibdbed430f2ff28d0ea2e67644075c1621d9fae53
(cherry picked from commit 3624d89c8b)
This commit is contained in:
Bartosz Dziewoński 2023-01-31 01:32:02 +01:00
parent bbf5fe6287
commit 20a79c55b7

View file

@ -452,24 +452,11 @@ class CommentUtils {
* Unwrap Parsoid sections
*
* @param Element $element Parent element, e.g. document body
* @param string|null $keepSection Section to keep
*/
public static function unwrapParsoidSections(
Element $element, string $keepSection = null
): void {
public static function unwrapParsoidSections( Element $element ): void {
$sections = DOMCompat::querySelectorAll( $element, 'section[data-mw-section-id]' );
foreach ( $sections as $section ) {
$parent = $section->parentNode;
$sectionId = $section->getAttribute( 'data-mw-section-id' );
// Copy section ID to first child (should be a heading)
if ( $sectionId !== null && $sectionId !== '' && intval( $sectionId ) > 0 ) {
$firstChild = $section->firstChild;
Assert::precondition( $firstChild instanceof Element, 'Section has a heading' );
$firstChild->setAttribute( 'data-mw-section-id', $sectionId );
}
if ( $keepSection !== null && $sectionId === $keepSection ) {
return;
}
while ( $section->firstChild ) {
$parent->insertBefore( $section->firstChild, $section );
}