This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved a test and added render integration tests.
- Loading branch information
Showing
2 changed files
with
82 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* globals document */ | ||
|
||
import View from '../../src/view/view'; | ||
import Position from '../../src/view/position'; | ||
import Range from '../../src/view/range'; | ||
|
||
import createRoot from './_utils/createRoot'; | ||
import { parse } from '../../src/dev-utils/view'; | ||
|
||
describe( 'Renderer\'s integration', () => { | ||
let view, domRoot, viewRoot; | ||
|
||
beforeEach( () => { | ||
view = new View(); | ||
viewRoot = createRoot( view.document ); | ||
domRoot = document.createElement( 'div' ); | ||
view.attachDomRoot( domRoot ); | ||
} ); | ||
|
||
// #1451 | ||
// <ul><li1>Foo</li1><li2><b>Bar</b></li2></ul> | ||
// -> | ||
// <ul><li1>Foo<ul><li2><b>Bar</b><i>Baz</i></li2></ul></li1></ul> | ||
it( 'renders changes made in detached elements', () => { | ||
const ul = parse( | ||
'<container:ul>' + | ||
'<container:li>Foo</container:li>' + | ||
'<container:li><attribute:b>Bar</attribute:b>Baz</container:li>' + | ||
'</container:ul>' ); | ||
|
||
// Render the initial content. | ||
view.change( writer => { | ||
writer.insert( Position.createAt( viewRoot ), ul ); | ||
} ); | ||
|
||
// Make some changes in a detached elements (li1, li2). | ||
view.change( writer => { | ||
const li1 = ul.getChild( 0 ); | ||
const li2 = ul.getChild( 1 ); | ||
|
||
writer.remove( Range.createIn( ul ) ); | ||
|
||
const innerUl = writer.createContainerElement( 'ul' ); | ||
|
||
writer.insert( Position.createAt( innerUl ), li2 ); | ||
writer.insert( Position.createAt( li1, 'end' ), innerUl ); | ||
|
||
const i = writer.createAttributeElement( 'i' ); | ||
|
||
writer.wrap( Range.createFromParentsAndOffsets( li2, 1, li2, 2 ), i ); | ||
|
||
writer.insert( Position.createAt( ul ), li1 ); | ||
} ); | ||
|
||
expect( domRoot.innerHTML ).to.equal( '<ul><li>Foo<ul><li><b>Bar</b><i>Baz</i></li></ul></li></ul>' ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters