mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
Only preserve data-parsoid/RESTBase ID on transclusion nodes
The previous attempt to fix this didn't preserve any attributes
but removing data-parsoid can result in a loss of wikitext formatting.
This reverts commit bdfd4b6d8f
.
Bug: T207325
Change-Id: I2a38e651d17262889eddb149c72c9e08b4e56ed0
This commit is contained in:
parent
1a426d8614
commit
c9b2e8b4d2
|
@ -38,8 +38,6 @@ OO.mixinClass( ve.ce.MWTransclusionNode, ve.ce.FocusableNode );
|
|||
|
||||
ve.ce.MWTransclusionNode.static.name = 'mwTransclusion';
|
||||
|
||||
ve.ce.MWTransclusionNode.static.renderHtmlAttributes = false;
|
||||
|
||||
ve.ce.MWTransclusionNode.static.primaryCommandName = 'transclusion';
|
||||
|
||||
ve.ce.MWTransclusionNode.static.iconWhenInvisible = 'puzzle';
|
||||
|
|
|
@ -60,6 +60,12 @@ ve.dm.MWTransclusionNode.static.matchFunction = function () {
|
|||
|
||||
ve.dm.MWTransclusionNode.static.enableAboutGrouping = true;
|
||||
|
||||
// We handle rendering ourselves, no need to render attributes from originalDomElements (T207325),
|
||||
// except for data-parsoid/RESTBase ID (T207325)
|
||||
ve.dm.MWTransclusionNode.static.preserveHtmlAttributes = function ( attribute ) {
|
||||
return [ 'data-parsoid', 'id' ].indexOf( attribute ) !== -1;
|
||||
};
|
||||
|
||||
ve.dm.MWTransclusionNode.static.getHashObject = function ( dataElement ) {
|
||||
return {
|
||||
type: dataElement.type,
|
||||
|
|
|
@ -1185,7 +1185,7 @@ ve.dm.mwExample.domToDataCases = {
|
|||
modify: function ( model ) {
|
||||
model.data.data[ 0 ].attributes.mw.parts[ 0 ].template.params[ '1' ].wt = 'Hello, globe!';
|
||||
},
|
||||
normalizedBody: ve.dm.mwExample.MWTransclusion.blockOpenModified,
|
||||
normalizedBody: ve.dm.mwExample.MWTransclusion.blockOpenModified.replace( /about="#mwt1"/, '' ),
|
||||
fromDataBody: ve.dm.mwExample.MWTransclusion.blockOpenFromDataModified,
|
||||
clipboardBody: ve.dm.mwExample.MWTransclusion.blockOpenModifiedClipboard,
|
||||
previewBody: false
|
||||
|
@ -1220,7 +1220,7 @@ ve.dm.mwExample.domToDataCases = {
|
|||
modify: function ( model ) {
|
||||
model.data.data[ 1 ].attributes.mw.parts[ 0 ].template.params[ '1' ].wt = '5,678';
|
||||
},
|
||||
normalizedBody: ve.dm.mwExample.MWTransclusion.inlineOpenModified + ve.dm.mwExample.MWTransclusion.inlineClose,
|
||||
normalizedBody: ve.dm.mwExample.MWTransclusion.inlineOpenModified.replace( /about="#mwt1"/, '' ) + ve.dm.mwExample.MWTransclusion.inlineClose,
|
||||
fromDataBody: ve.dm.mwExample.MWTransclusion.inlineOpenFromDataModified + ve.dm.mwExample.MWTransclusion.inlineClose,
|
||||
clipboardBody: ve.dm.mwExample.MWTransclusion.inlineOpenModifiedClipboard + ve.dm.mwExample.MWTransclusion.inlineClose,
|
||||
previewBody: false
|
||||
|
|
|
@ -19,6 +19,7 @@ QUnit.test( 'Diffing', function ( assert ) {
|
|||
expected:
|
||||
'<div class="ve-ui-diffElement-doc-child-change">' +
|
||||
( ve.dm.mwExample.MWTransclusion.blockOpenModified + ve.dm.mwExample.MWTransclusion.blockContent )
|
||||
// FIXME: Use DOM modification instead of string replaces
|
||||
.replace( /#mwt1"/g, '#mwt1" data-diff-action="structural-change" data-diff-id="0"' ) +
|
||||
'</div>',
|
||||
expectedDescriptions: [
|
||||
|
@ -33,6 +34,7 @@ QUnit.test( 'Diffing', function ( assert ) {
|
|||
expected:
|
||||
'<div class="ve-ui-diffElement-doc-child-change">' +
|
||||
ve.dm.mwExample.MWBlockImage.html
|
||||
// FIXME: Use DOM modification instead of string replaces
|
||||
.replace( 'width="1"', 'width="3"' )
|
||||
.replace( 'href="Foo"', 'href="' + ve.resolveUrl( 'Foo', ve.dm.example.base ) + '"' )
|
||||
.replace( 'foobar"', 'foobar" data-diff-action="structural-change" data-diff-id="0"' ) +
|
||||
|
|
Loading…
Reference in a new issue