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:
Catrope 2013-05-07 21:22:22 -07:00
parent 9f06258b8e
commit 85d67ce44f
2 changed files with 8 additions and 10 deletions

View file

@ -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 */

View file

@ -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="{&quot;src&quot;:&quot;<ref>No name</ref>&quot;}">' +
'</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>',