mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-27 04:06: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.toDataElement = function ( domElements ) {
|
||||
var html = $( '<div>', domElements[0].ownerDocument ).append( $( domElements ).clone() ).html();
|
||||
ve.dm.MWReferenceListNode.static.storeHtmlAttributes = false;
|
||||
|
||||
ve.dm.MWReferenceListNode.static.toDataElement = function ( domElements ) {
|
||||
return {
|
||||
'type': this.name,
|
||||
'attributes': {
|
||||
'html': html
|
||||
'domElements': ve.copyArray( domElements )
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
ve.dm.MWReferenceListNode.static.toDomElements = function ( dataElement, doc ) {
|
||||
return [ doc.createElement( 'ol' ) ];
|
||||
ve.dm.MWReferenceListNode.static.toDomElements = function ( dataElement ) {
|
||||
return dataElement.attributes.domElements;
|
||||
};
|
||||
|
||||
/* Registration */
|
||||
|
|
|
@ -1050,7 +1050,7 @@ ve.dm.example.domToDataCases = {
|
|||
'</span>' +
|
||||
'</p>' +
|
||||
'<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>' +
|
||||
'</body>',
|
||||
'data': [
|
||||
|
@ -1119,9 +1119,7 @@ ve.dm.example.domToDataCases = {
|
|||
{
|
||||
'type': 'MWreferenceList',
|
||||
'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>',
|
||||
'html/0/class': 'references',
|
||||
'html/0/typeof': 'mw:Object/References'
|
||||
'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()
|
||||
}
|
||||
},
|
||||
{ 'type': '/MWreferenceList' },
|
||||
|
@ -1161,7 +1159,7 @@ ve.dm.example.domToDataCases = {
|
|||
'data-parsoid="{"src":"<ref>No name</ref>"}">' +
|
||||
'</span>' +
|
||||
'</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': {
|
||||
'html': '<body><p>a<tt class="foo">b</tt>c</p></body>',
|
||||
|
|
Loading…
Reference in a new issue