Use DOMUtils::hasTypeOf/matchTypeOf/addTypeOf consistently

The `typeof` attribute is a space-separated list.  Use consistent methods
to test for membership in that list.

Try to set a good example by using ::addTypeOf() in general to set the
value of the 'typeof' attribute, except when we are transferring values
from one node to another.

Move the *TypeOf method to DOMUtils from DOMDataUtils, eliminating some
duplication.  Create Wikimedia\Parsoid\Ext\DOMUtils so that extensions
can use these methods as well.

Change-Id: Ib2ef827ef1cf5e31a1ef0a5034cdd3d9a0212bdb
This commit is contained in:
C. Scott Ananian 2020-04-21 21:31:02 -04:00
parent a174963f3e
commit 46f749b92f

View file

@ -10,12 +10,12 @@ use stdClass;
use Wikimedia\Assert\Assert;
use Wikimedia\Parsoid\Core\DomSourceRange;
use Wikimedia\Parsoid\Ext\DOMDataUtils;
use Wikimedia\Parsoid\Ext\DOMUtils;
use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
use Wikimedia\Parsoid\Ext\PHPUtils;
use Wikimedia\Parsoid\Ext\WTUtils;
use Wikimedia\Parsoid\Utils\DOMCompat;
use Wikimedia\Parsoid\Utils\DOMUtils;
class References extends ExtensionTagHandler {
/**
@ -181,7 +181,7 @@ class References extends ExtensionTagHandler {
'typeof' => $nodeType
]
);
DOMDataUtils::addTypeOf( $linkBack, 'mw:Extension/ref' );
DOMUtils::addTypeOf( $linkBack, 'mw:Extension/ref' );
$dataParsoid = new stdClass;
if ( isset( $nodeDp->src ) ) {
$dataParsoid->src = $nodeDp->src;