Prioritize body->html over body->id when diffing refs

Just to keep things consistent since that's the precedence we use when
serializing.

Change-Id: I1456b6a21ae050d58d15620e501a14c29a64f9e3
This commit is contained in:
Arlo Breault 2022-04-28 14:49:32 -04:00
parent c3f34b7360
commit e3c4e96c71

View file

@ -191,7 +191,17 @@ class Ref extends ExtensionTagHandler {
$origDataMw = DOMDataUtils::getDataMw( $origNode );
$editedDataMw = DOMDataUtils::getDataMw( $editedNode );
if ( isset( $origDataMw->body->id ) && isset( $editedDataMw->body->id ) ) {
if ( isset( $origDataMw->body->html ) && isset( $editedDataMw->body->html ) ) {
$origFragment = $extApi->htmlToDom(
$origDataMw->body->html, $origNode->ownerDocument,
[ 'markNew' => true ]
);
$editedFragment = $extApi->htmlToDom(
$editedDataMw->body->html, $editedNode->ownerDocument,
[ 'markNew' => true ]
);
return call_user_func( $domDiff, $origFragment, $editedFragment );
} elseif ( isset( $origDataMw->body->id ) && isset( $editedDataMw->body->id ) ) {
$origId = $origDataMw->body->id;
$editedId = $editedDataMw->body->id;
@ -226,16 +236,6 @@ class Ref extends ExtensionTagHandler {
);
}
}
} elseif ( isset( $origDataMw->body->html ) && isset( $editedDataMw->body->html ) ) {
$origFragment = $extApi->htmlToDom(
$origDataMw->body->html, $origNode->ownerDocument,
[ 'markNew' => true ]
);
$editedFragment = $extApi->htmlToDom(
$editedDataMw->body->html, $editedNode->ownerDocument,
[ 'markNew' => true ]
);
return call_user_func( $domDiff, $origFragment, $editedFragment );
}
// FIXME: Similar to DOMDiff::subtreeDiffers, maybe $editNode should