From 85d67ce44f66940623ef4913e7865941b58beeb3 Mon Sep 17 00:00:00 2001 From: Catrope Date: Tue, 7 May 2013 21:22:22 -0700 Subject: [PATCH] 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 (
  • -->
  • ) in the test case. Change-Id: I36bf8bade8118e07a75eb6f3a2427a00ef4915d7 --- modules/ve/dm/nodes/ve.dm.MWReferenceListNode.js | 10 +++++----- modules/ve/test/dm/ve.dm.example.js | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/ve/dm/nodes/ve.dm.MWReferenceListNode.js b/modules/ve/dm/nodes/ve.dm.MWReferenceListNode.js index 4a387ead44..adcd5e0d69 100644 --- a/modules/ve/dm/nodes/ve.dm.MWReferenceListNode.js +++ b/modules/ve/dm/nodes/ve.dm.MWReferenceListNode.js @@ -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 = $( '
    ', 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 */ diff --git a/modules/ve/test/dm/ve.dm.example.js b/modules/ve/test/dm/ve.dm.example.js index b0d6be8186..4bcb1a968b 100644 --- a/modules/ve/test/dm/ve.dm.example.js +++ b/modules/ve/test/dm/ve.dm.example.js @@ -1050,7 +1050,7 @@ ve.dm.example.domToDataCases = { '' + '

    ' + '
      ' + - '
    1. u2191Quux
    2. ' + + '
    3. u2191Quux
    4. ' + '
    ' + '', 'data': [ @@ -1119,9 +1119,7 @@ ve.dm.example.domToDataCases = { { 'type': 'MWreferenceList', 'attributes': { - 'html': '
    1. u2191Quux
    ', - 'html/0/class': 'references', - 'html/0/typeof': 'mw:Object/References' + 'domElements': $( '
    1. u2191Quux
    ' ).get() } }, { 'type': '/MWreferenceList' }, @@ -1161,7 +1159,7 @@ ve.dm.example.domToDataCases = { 'data-parsoid="{"src":"No name"}">' + '' + '

    ' + - '
      ' + '
      1. u2191Quux
      ' }, 'paragraph with alienInline inside': { 'html': '

      abc

      ',