mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Highlight when we have a valid follow
Rather than using no errors as proxy. Change-Id: I78c445838de2d4f5f6a0f17e5bb38996674ca999
This commit is contained in:
parent
deb9451c15
commit
e3484acfc6
|
@ -148,7 +148,12 @@ class Ref extends ExtensionTagHandler {
|
|||
$hasRefName = strlen( $dataMw->attrs->name ?? '' ) > 0;
|
||||
$hasFollow = strlen( $dataMw->attrs->follow ?? '' ) > 0;
|
||||
|
||||
if ( $hasFollow && !DOMUtils::hasTypeOf( $node, 'mw:Error' ) ) {
|
||||
// FIXME: This isn't exactly right since a valid follow could
|
||||
// potentially produce some other type of error, so this may
|
||||
// need some more smarts
|
||||
$validFollow = $hasFollow && !DOMUtils::hasTypeOf( $node, 'mw:Error' );
|
||||
|
||||
if ( $validFollow ) {
|
||||
$about = $node->getAttribute( 'about' );
|
||||
$followNode = DOMCompat::querySelector(
|
||||
$bodyElt, "span[typeof~='mw:Cite/Follow'][about='{$about}']"
|
||||
|
|
|
@ -170,6 +170,8 @@ class References extends ExtensionTagHandler {
|
|||
$hasRefName = strlen( $refName ) > 0;
|
||||
$hasFollow = strlen( $followName ) > 0;
|
||||
|
||||
$validFollow = false;
|
||||
|
||||
if ( $hasFollow ) {
|
||||
if ( $hasRefName ) {
|
||||
$errs[] = [ 'key' => 'cite_error_ref_too_many_keys' ];
|
||||
|
@ -178,6 +180,7 @@ class References extends ExtensionTagHandler {
|
|||
// been defined
|
||||
$group = $refsData->getRefGroup( $groupName );
|
||||
if ( isset( $group->indexByName[$followName] ) ) {
|
||||
$validFollow = true;
|
||||
$ref = $group->indexByName[$followName];
|
||||
|
||||
$span = $c->ownerDocument->createElement( 'span' );
|
||||
|
@ -262,7 +265,7 @@ class References extends ExtensionTagHandler {
|
|||
DOMUtils::addAttributes( $linkBack, [
|
||||
'about' => $about,
|
||||
'class' => 'mw-ref',
|
||||
'id' => ( $nestedInReferences || ( $hasFollow && count( $errs ) === 0 ) ) ?
|
||||
'id' => ( $nestedInReferences || $validFollow ) ?
|
||||
null : ( $ref->name ? $lastLinkback : $ref->id ),
|
||||
'rel' => 'dc:references',
|
||||
'typeof' => $nodeType
|
||||
|
@ -294,8 +297,8 @@ class References extends ExtensionTagHandler {
|
|||
}
|
||||
DOMDataUtils::setDataMw( $linkBack, $dmw );
|
||||
|
||||
// FIXME (T263052) This should be moved to CSS
|
||||
if ( $hasFollow && count( $errs ) === 0 ) {
|
||||
// FIXME(T263052): This should be moved to CSS
|
||||
if ( $validFollow ) {
|
||||
$linkBack->setAttribute( 'style', 'display: none;' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue