| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
QUnit.module( 've.ce.ContentBranchNode (MW)' ); |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
QUnit.test.each( 'getRenderedContents', { |
| 14 |
'Annotation spanning text and inline nodes': { |
| 15 |
data: [ |
| 16 |
{ type: 'paragraph' }, |
| 17 |
'a', |
| 18 |
[ 'b', [ { type: 'textStyle/bold' } ] ], |
| 19 |
{ |
| 20 |
type: 'mwEntity', |
| 21 |
attributes: { character: 'c' }, |
| 22 |
annotations: [ { type: 'textStyle/bold' } ] |
| 23 |
}, |
| 24 |
{ type: '/mwEntity' }, |
| 25 |
[ 'd', [ { type: 'textStyle/bold' } ] ], |
| 26 |
{ |
| 27 |
type: 'alienInline', |
| 28 |
originalDomElements: $.parseHTML( '<span rel="ve:Alien">e</span>' ), |
| 29 |
annotations: [ { type: 'textStyle/bold' } ] |
| 30 |
}, |
| 31 |
{ type: '/alienInline' }, |
| 32 |
{ type: '/paragraph' } |
| 33 |
], |
| 34 |
html: ve.dm.example.singleLine` |
| 35 |
a |
| 36 |
<b> |
| 37 |
b |
| 38 |
<span class="ve-ce-leafNode ve-ce-mwEntityNode" contenteditable="false">c</span> |
| 39 |
d |
| 40 |
<span rel="ve:Alien" class="ve-ce-focusableNode ve-ce-leafNode" contenteditable="false">e</span> |
| 41 |
</b> |
| 42 |
` |
| 43 |
} |
| 44 |
}, ( assert, { data, html } ) => { |
| 45 |
const doc = new ve.dm.Document( ve.dm.example.preprocessAnnotations( data ) ); |
| 46 |
const $wrapper = $( new ve.ce.ParagraphNode( doc.getDocumentNode().getChildren()[ 0 ] ).getRenderedContents() ); |
| 47 |
|
| 48 |
$wrapper.find( '.ve-ce-textStyleAnnotation' ).removeAttr( 'class' ); |
| 49 |
|
| 50 |
assert.equalDomElement( $wrapper[ 0 ], $( '<div>' ).html( html )[ 0 ] ); |
| 51 |
} ); |