mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-30 09:44:24 +00:00
Apply recent JS changes to automatically-generated PHP port
This applies the JS changes from the following recently-merged patches: 6679c3bf Protect data-object-id attribute d4e76d5b Fix new linter category to enable code work with templates e567db8d Tweak storeDataAttribs to suppress DOM nodes in data-parsoid.tmp 16603953 Fix setting dsr on body for genTest 3a84a9dd Fix stashing data attributes for mw:StartTag 22c4a19a Remove redundant dataParsoid call ed7b0ba0 Fix crasher in newly added linter category 505a357b Linter.js: Add new function to detect the use of links in links 8885b20e Move redlink updating into lib/parse.js ccfce23d templatedepth is either an int or false 6d1571bd Move language conversion work into lib/parse.js 5a89c7de Avoid serialize/parse of data attributes when treebuilding 021d9958 Rename `document.env` to `document.bag` c03ba494 Use XMLSerializer on both PHP & JS side in the DOM pass test script e0c3cca9 Use env.createDocument in lib/api/apiUtils.js550d3d71
Use a bag-on-the-side implementation for node data f8de8b25 Add bin/inspectTokenizer.js db704eea Add ability to splice a PHP transformer into the pipelinea8be3ad6
Fix crasher in cite extension from accessing data after it's stored 2874f200 Simplify and clean up stops usage 6368265d Add some strategic isElt guards 5ae9553f DRY out transform test runners + tweak genTest to enable that b0f2adc6 Assert that the .dataobject isn't touched after storing attrs on a node 1ce6a98d Skip separators when looking for the next th/td Change-Id: I6a66ecb061e7ee7ed53feba1895dd315d9324715
This commit is contained in:
parent
550d3d71eb
commit
25385a06e8
|
@ -10,8 +10,6 @@
|
|||
|
||||
namespace Parsoid;
|
||||
|
||||
use Parsoid\domino as domino;
|
||||
|
||||
$ParsoidExtApi = $module->parent->require( './extapi.js' )->versionCheck( '^0.10.0' );
|
||||
$temp0 =
|
||||
|
||||
|
@ -111,7 +109,9 @@ Ref::prototype::serialHandler = [
|
|||
// n.b. this is going to drop any diff markers but since
|
||||
// the dom differ doesn't traverse into extension content
|
||||
// none should exist anyways.
|
||||
$html = ContentUtils::ppToXML( $bodyElt, [ 'innerXML' => true ] );
|
||||
DOMDataUtils::visitAndStoreDataAttribs( $bodyElt );
|
||||
$html = ContentUtils::toXML( $bodyElt, [ 'innerXML' => true ] );
|
||||
DOMDataUtils::visitAndLoadDataAttribs( $bodyElt );
|
||||
} else {
|
||||
// Some extra debugging for VisualEditor
|
||||
$extraDebug = '';
|
||||
|
@ -346,11 +346,7 @@ function References( $cite ) {
|
|||
$this->cite = $cite;
|
||||
}
|
||||
|
||||
$dummyDoc = domino::createDocument();
|
||||
|
||||
$createReferences = function ( $env, $body, $refsOpts, $modifyDp, $autoGenerated ) use ( &$dummyDoc, &$DOMUtils, &$DOMDataUtils ) {
|
||||
$doc = ( $body ) ? $body->ownerDocument : $dummyDoc;
|
||||
|
||||
$createReferences = function ( $env, $doc, $body, $refsOpts, $modifyDp, $autoGenerated ) use ( &$DOMUtils, &$DOMDataUtils ) {
|
||||
$ol = $doc->createElement( 'ol' );
|
||||
$ol->classList->add( 'mw-references' );
|
||||
$ol->classList->add( 'references' );
|
||||
|
@ -409,7 +405,7 @@ References::prototype::toDOM = function ( $state, $content, $args ) use ( &$Pars
|
|||
], TokenUtils::kvToHash( $args, true )
|
||||
);
|
||||
|
||||
$frag = $createReferences( $state->env, $doc->body, $refsOpts, function ( $dp ) use ( &$state ) {
|
||||
$frag = $createReferences( $state->env, $doc, $doc->body, $refsOpts, function ( $dp ) use ( &$state ) {
|
||||
$dp->src = $state->extToken->getAttribute( 'source' );
|
||||
// Redundant - also present on doc.body.firstChild, but feels cumbersome to use
|
||||
$dp->selfClose = $state->extToken->dataAttribs->selfClose;
|
||||
|
@ -448,7 +444,7 @@ References::prototype::extractRefFromNode = function ( $node, $refsData, $cite,
|
|||
$cDp = DOMDataUtils::getDataParsoid( $c );
|
||||
$refDmw = DOMDataUtils::getDataMw( $c );
|
||||
if ( !$cDp->empty && hasRef( $c ) ) { // nested ref-in-ref
|
||||
$_processRefs( $cite, $refsData, $c );
|
||||
$_processRefs( $env, $cite, $refsData, $c );
|
||||
}
|
||||
DOMDataUtils::visitAndStoreDataAttribs( $c );
|
||||
|
||||
|
@ -626,8 +622,8 @@ References::prototype::insertMissingReferencesIntoDOM = function ( $refsData, $n
|
|||
$env = $refsData->env;
|
||||
$doc = $node->ownerDocument;
|
||||
|
||||
$refsData->refGroups->forEach( function ( $refsValue, $refsGroup ) use ( &$createReferences, &$env, &$node, &$doc, &$refsData ) {
|
||||
$frag = $createReferences( $env, null, [
|
||||
$refsData->refGroups->forEach( function ( $refsValue, $refsGroup ) use ( &$createReferences, &$env, &$doc, &$node, &$refsData ) {
|
||||
$frag = $createReferences( $env, $doc, null, [
|
||||
'group' => $refsGroup,
|
||||
'responsive' => null
|
||||
], function ( $dp ) {
|
||||
|
@ -733,7 +729,7 @@ $_processRefsInReferences = function ( $cite, $refsData, $node, $referencesId,
|
|||
}
|
||||
};
|
||||
|
||||
$_processRefs = function ( $cite, $refsData, $node ) use ( &$DOMUtils, &$WTUtils, &$DOMDataUtils, &$_processRefsInReferences, &$ContentUtils, &$_processRefs ) {
|
||||
$_processRefs = function ( $env, $cite, $refsData, $node ) use ( &$DOMUtils, &$WTUtils, &$DOMDataUtils, &$_processRefsInReferences, &$ContentUtils, &$_processRefs ) {
|
||||
$child = $node->firstChild;
|
||||
while ( $child !== null ) {
|
||||
$nextChild = $child->nextSibling;
|
||||
|
@ -781,13 +777,13 @@ $_processRefs = function ( $cite, $refsData, $node ) use ( &$DOMUtils, &$WTUtils
|
|||
if ( $caption ) {
|
||||
// Extract the caption HTML, build the DOM, process refs,
|
||||
// serialize to HTML, update the caption HTML.
|
||||
$captionDOM = ContentUtils::ppToDOM( $caption );
|
||||
$_processRefs( $cite, $refsData, $captionDOM );
|
||||
$captionDOM = ContentUtils::ppToDOM( $env, $caption );
|
||||
$_processRefs( $env, $cite, $refsData, $captionDOM );
|
||||
$dmw->caption = ContentUtils::ppToXML( $captionDOM, [ 'innerXML' => true ] );
|
||||
}
|
||||
}
|
||||
if ( $child->hasChildNodes() ) {
|
||||
$_processRefs( $cite, $refsData, $child );
|
||||
$_processRefs( $env, $cite, $refsData, $child );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -843,7 +839,7 @@ $Cite = function () {
|
|||
Cite::prototype::_wt2htmlPostProcessor = function ( $body, $env, $options, $atTopLevel ) use ( &$_processRefs ) {
|
||||
if ( $atTopLevel ) {
|
||||
$refsData = new ReferencesData( $env );
|
||||
$_processRefs( $this, $refsData, $body );
|
||||
$_processRefs( $env, $this, $refsData, $body );
|
||||
$this->references->insertMissingReferencesIntoDOM( $refsData, $body );
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue