Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Html2Wt\DOMDiff Class Reference

A DOM diff helper class. More...

Public Member Functions

 __construct (Env $env)
 
 diff (Element $nodeA, Element $nodeB)
 Diff two HTML documents, and add / update data-parsoid-diff attributes with change information.
 
 treeEquals (Node $nodeA, Node $nodeB, bool $deep)
 Test if two DOM nodes are equal.
 
 doDOMDiff (Node $baseParentNode, Node $newParentNode)
 Diff two DOM trees by comparing them node-by-node.
 

Public Attributes

 $env
 
 $extApi
 
 $specializedAttribHandlers
 

Detailed Description

A DOM diff helper class.

Compares two DOMs and annotates a copy of the passed-in DOM with change information for the selective serializer.

Member Function Documentation

◆ diff()

Wikimedia\Parsoid\Html2Wt\DOMDiff::diff ( Element  $nodeA,
Element  $nodeB 
)

Diff two HTML documents, and add / update data-parsoid-diff attributes with change information.

Parameters
Element$nodeA
Element$nodeB
Returns
array

◆ doDOMDiff()

Wikimedia\Parsoid\Html2Wt\DOMDiff::doDOMDiff ( Node  $baseParentNode,
Node  $newParentNode 
)

Diff two DOM trees by comparing them node-by-node.

TODO: Implement something more intelligent like http://gregory.cobena.free.fr/www/Publications/%5BICDE2002%5D%20XyDiff%20-%20published%20version.pdf, which uses hash signatures of subtrees to efficiently detect moves / wrapping.

Adds / updates a data-parsoid-diff structure with change information.

Returns true if subtree is changed, false otherwise.

TODO: Assume typical CSS white-space, so ignore ws diffs in non-pre content.

Parameters
Node$baseParentNode
Node$newParentNode
Returns
bool

◆ treeEquals()

Wikimedia\Parsoid\Html2Wt\DOMDiff::treeEquals ( Node  $nodeA,
Node  $nodeB,
bool  $deep 
)

Test if two DOM nodes are equal.

Parameters
Node$nodeA
Node$nodeB
bool$deep
Returns
bool

The documentation for this class was generated from the following file: