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

View file

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