mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-27 12:16:51 +00:00
Do proper HTML preservation in ve.dm.MWReferenceListNode
Store the HTML as a domElements array like everywhere else, rather than as a string. Also disable HTML attribute preservation because there's no point doing that when we're already preserving all of the HTML. Also fixed a misnamed attribute (<li li="foo"> --> <li id="foo">) in the test case. Change-Id: I36bf8bade8118e07a75eb6f3a2427a00ef4915d7
This commit is contained in:
parent
9f06258b8e
commit
85d67ce44f
|
@ -31,19 +31,19 @@ ve.dm.MWReferenceListNode.static.matchTagNames = null;
|
||||||
|
|
||||||
ve.dm.MWReferenceListNode.static.matchRdfaTypes = [ 'mw:Object/References' ];
|
ve.dm.MWReferenceListNode.static.matchRdfaTypes = [ 'mw:Object/References' ];
|
||||||
|
|
||||||
ve.dm.MWReferenceListNode.static.toDataElement = function ( domElements ) {
|
ve.dm.MWReferenceListNode.static.storeHtmlAttributes = false;
|
||||||
var html = $( '<div>', domElements[0].ownerDocument ).append( $( domElements ).clone() ).html();
|
|
||||||
|
|
||||||
|
ve.dm.MWReferenceListNode.static.toDataElement = function ( domElements ) {
|
||||||
return {
|
return {
|
||||||
'type': this.name,
|
'type': this.name,
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'html': html
|
'domElements': ve.copyArray( domElements )
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
ve.dm.MWReferenceListNode.static.toDomElements = function ( dataElement, doc ) {
|
ve.dm.MWReferenceListNode.static.toDomElements = function ( dataElement ) {
|
||||||
return [ doc.createElement( 'ol' ) ];
|
return dataElement.attributes.domElements;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Registration */
|
/* Registration */
|
||||||
|
|
|
@ -1050,7 +1050,7 @@ ve.dm.example.domToDataCases = {
|
||||||
'</span>' +
|
'</span>' +
|
||||||
'</p>' +
|
'</p>' +
|
||||||
'<ol class="references" typeof="mw:Object/References">' +
|
'<ol class="references" typeof="mw:Object/References">' +
|
||||||
'<li li="cite_note-quux-2"><a href="#cite_ref-quux-2-0">u2191</a>Quux</li>' +
|
'<li id="cite_note-quux-2"><a href="#cite_ref-quux-2-0">u2191</a>Quux</li>' +
|
||||||
'</ol>' +
|
'</ol>' +
|
||||||
'</body>',
|
'</body>',
|
||||||
'data': [
|
'data': [
|
||||||
|
@ -1119,9 +1119,7 @@ ve.dm.example.domToDataCases = {
|
||||||
{
|
{
|
||||||
'type': 'MWreferenceList',
|
'type': 'MWreferenceList',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'html': '<ol class="references" typeof="mw:Object/References"><li li="cite_note-quux-2"><a href="#cite_ref-quux-2-0">u2191</a>Quux</li></ol>',
|
'domElements': $( '<ol class="references" typeof="mw:Object/References"><li id="cite_note-quux-2"><a href="#cite_ref-quux-2-0">u2191</a>Quux</li></ol>' ).get()
|
||||||
'html/0/class': 'references',
|
|
||||||
'html/0/typeof': 'mw:Object/References'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ 'type': '/MWreferenceList' },
|
{ 'type': '/MWreferenceList' },
|
||||||
|
@ -1161,7 +1159,7 @@ ve.dm.example.domToDataCases = {
|
||||||
'data-parsoid="{"src":"<ref>No name</ref>"}">' +
|
'data-parsoid="{"src":"<ref>No name</ref>"}">' +
|
||||||
'</span>' +
|
'</span>' +
|
||||||
'</p>' +
|
'</p>' +
|
||||||
'<ol class="references" typeof="mw:Object/References"></ol>'
|
'<ol class="references" typeof="mw:Object/References"><li id="cite_note-quux-2"><a href="#cite_ref-quux-2-0">u2191</a>Quux</li></ol>'
|
||||||
},
|
},
|
||||||
'paragraph with alienInline inside': {
|
'paragraph with alienInline inside': {
|
||||||
'html': '<body><p>a<tt class="foo">b</tt>c</p></body>',
|
'html': '<body><p>a<tt class="foo">b</tt>c</p></body>',
|
||||||
|
|
Loading…
Reference in a new issue