|
|
@@ -63,7 +63,7 @@ describe( 'UpcastWriter', () => {
|
|
|
const el = view.getChild( 2 );
|
|
|
const newChild = new Element( 'span' );
|
|
|
|
|
|
- const appended = writer.appendChild( el, newChild );
|
|
|
+ const appended = writer.appendChild( newChild, el );
|
|
|
|
|
|
expect( appended ).to.equal( 1 );
|
|
|
expect( newChild.parent ).to.equal( el );
|
|
|
@@ -75,7 +75,7 @@ describe( 'UpcastWriter', () => {
|
|
|
const newChild1 = new Element( 'p' );
|
|
|
const newChild2 = new Element( 'h2' );
|
|
|
|
|
|
- const appended = writer.appendChild( el, [ newChild1, newChild2 ] );
|
|
|
+ const appended = writer.appendChild( [ newChild1, newChild2 ], el );
|
|
|
|
|
|
expect( appended ).to.equal( 2 );
|
|
|
expect( newChild1.parent ).to.equal( el );
|
|
|
@@ -87,7 +87,7 @@ describe( 'UpcastWriter', () => {
|
|
|
const el = view.getChild( 3 );
|
|
|
const newChild = new Element( 'li' );
|
|
|
|
|
|
- const appended = writer.appendChild( el, newChild );
|
|
|
+ const appended = writer.appendChild( newChild, el );
|
|
|
|
|
|
expect( appended ).to.equal( 1 );
|
|
|
expect( newChild.parent ).to.equal( el );
|
|
|
@@ -97,7 +97,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should append element to DocumentFragment element', () => {
|
|
|
const newChild = new Element( 'p' );
|
|
|
|
|
|
- const appended = writer.appendChild( view, newChild );
|
|
|
+ const appended = writer.appendChild( newChild, view );
|
|
|
|
|
|
expect( appended ).to.equal( 1 );
|
|
|
expect( newChild.parent ).to.equal( view );
|
|
|
@@ -110,7 +110,7 @@ describe( 'UpcastWriter', () => {
|
|
|
const el = view.getChild( 2 );
|
|
|
const newChild = new Element( 'span' );
|
|
|
|
|
|
- const inserted = writer.insertChild( el, 0, newChild );
|
|
|
+ const inserted = writer.insertChild( 0, newChild, el );
|
|
|
|
|
|
expect( inserted ).to.equal( 1 );
|
|
|
expect( newChild.parent ).to.equal( el );
|
|
|
@@ -123,7 +123,7 @@ describe( 'UpcastWriter', () => {
|
|
|
const newChild1 = new Element( 'blockquote' );
|
|
|
const newChild2 = new Element( 'h2' );
|
|
|
|
|
|
- const inserted = writer.insertChild( el, 2, [ newChild1, newChild2 ] );
|
|
|
+ const inserted = writer.insertChild( 2, [ newChild1, newChild2 ], el );
|
|
|
|
|
|
expect( inserted ).to.equal( 2 );
|
|
|
expect( newChild1.parent ).to.equal( el );
|
|
|
@@ -137,7 +137,7 @@ describe( 'UpcastWriter', () => {
|
|
|
const el = view.getChild( 3 );
|
|
|
const newChild = new Element( 'li' );
|
|
|
|
|
|
- const inserted = writer.insertChild( el, 1, newChild );
|
|
|
+ const inserted = writer.insertChild( 1, newChild, el );
|
|
|
|
|
|
expect( inserted ).to.equal( 1 );
|
|
|
expect( newChild.parent ).to.equal( el );
|
|
|
@@ -148,7 +148,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should insert element to DocumentFragment element', () => {
|
|
|
const newChild = new Element( 'p' );
|
|
|
|
|
|
- const inserted = writer.insertChild( view, 4, newChild );
|
|
|
+ const inserted = writer.insertChild( 4, newChild, view );
|
|
|
|
|
|
expect( inserted ).to.equal( 1 );
|
|
|
expect( newChild.parent ).to.equal( view );
|
|
|
@@ -162,7 +162,7 @@ describe( 'UpcastWriter', () => {
|
|
|
const el = view.getChild( 1 );
|
|
|
const toRemove = el.getChild( 0 );
|
|
|
|
|
|
- const removed = writer.removeChildren( el, 0 );
|
|
|
+ const removed = writer.removeChildren( 0, 1, el );
|
|
|
|
|
|
expect( removed.length ).to.equal( 1 );
|
|
|
expect( removed[ 0 ] ).to.equal( toRemove );
|
|
|
@@ -174,7 +174,7 @@ describe( 'UpcastWriter', () => {
|
|
|
const toRemove1 = el.getChild( 1 );
|
|
|
const toRemove2 = el.getChild( 2 );
|
|
|
|
|
|
- const removed = writer.removeChildren( el, 1, 2 );
|
|
|
+ const removed = writer.removeChildren( 1, 2, el );
|
|
|
|
|
|
expect( removed.length ).to.equal( 2 );
|
|
|
expect( removed[ 0 ] ).to.equal( toRemove1 );
|
|
|
@@ -185,7 +185,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should remove child from DocumentFragment element', () => {
|
|
|
const toRemove = view.getChild( 2 );
|
|
|
|
|
|
- const removed = writer.removeChildren( view, 2 );
|
|
|
+ const removed = writer.removeChildren( 2, 1, view );
|
|
|
|
|
|
expect( removed.length ).to.equal( 1 );
|
|
|
expect( removed[ 0 ] ).to.equal( toRemove );
|
|
|
@@ -262,7 +262,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should rename simple element', () => {
|
|
|
const el = view.getChild( 0 ).getChild( 1 );
|
|
|
|
|
|
- const renamed = writer.rename( el, 'i' );
|
|
|
+ const renamed = writer.rename( 'i', el );
|
|
|
|
|
|
expect( renamed ).to.not.equal( el );
|
|
|
expect( renamed ).to.equal( view.getChild( 0 ).getChild( 1 ) );
|
|
|
@@ -273,7 +273,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should rename direct root (DocumentFragment) child element', () => {
|
|
|
const el = view.getChild( 1 );
|
|
|
|
|
|
- const renamed = writer.rename( el, 'h3' );
|
|
|
+ const renamed = writer.rename( 'h3', el );
|
|
|
|
|
|
expect( renamed ).to.not.equal( el );
|
|
|
expect( renamed ).to.equal( view.getChild( 1 ) );
|
|
|
@@ -282,9 +282,9 @@ describe( 'UpcastWriter', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should have no effect on detached element', () => {
|
|
|
- const element = new Element( 'h2' );
|
|
|
+ const el = new Element( 'h2' );
|
|
|
|
|
|
- const renamed = writer.rename( element, 'h3' );
|
|
|
+ const renamed = writer.rename( 'h3', el );
|
|
|
|
|
|
expect( renamed ).to.null;
|
|
|
expect( view.childCount ).to.equal( 4 );
|
|
|
@@ -295,7 +295,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should add new attribute', () => {
|
|
|
const el = view.getChild( 0 );
|
|
|
|
|
|
- writer.setAttribute( el, 'testAttr', 'testVal' );
|
|
|
+ writer.setAttribute( 'testAttr', 'testVal', el );
|
|
|
|
|
|
expect( el.getAttribute( 'testAttr' ) ).to.equal( 'testVal' );
|
|
|
} );
|
|
|
@@ -303,7 +303,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should update existing attribute', () => {
|
|
|
const el = view.getChild( 1 );
|
|
|
|
|
|
- writer.setAttribute( el, 'data-attr', 'foo' );
|
|
|
+ writer.setAttribute( 'data-attr', 'foo', el );
|
|
|
|
|
|
expect( el.getAttribute( 'data-attr' ) ).to.equal( 'foo' );
|
|
|
} );
|
|
|
@@ -313,7 +313,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should remove existing attribute', () => {
|
|
|
const el = view.getChild( 1 );
|
|
|
|
|
|
- writer.removeAttribute( el, 'data-attr' );
|
|
|
+ writer.removeAttribute( 'data-attr', el );
|
|
|
|
|
|
expect( el.hasAttribute( 'data-attr' ) ).to.false;
|
|
|
} );
|
|
|
@@ -321,7 +321,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should have no effect if attribute does not exists', () => {
|
|
|
const el = view.getChild( 0 );
|
|
|
|
|
|
- writer.removeAttribute( el, 'non-existent' );
|
|
|
+ writer.removeAttribute( 'non-existent', el );
|
|
|
|
|
|
expect( el.hasAttribute( 'non-existent' ) ).to.false;
|
|
|
} );
|
|
|
@@ -331,7 +331,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should add new classes if no classes', () => {
|
|
|
const el = view.getChild( 2 );
|
|
|
|
|
|
- writer.addClass( el, [ 'foo', 'bar' ] );
|
|
|
+ writer.addClass( [ 'foo', 'bar' ], el );
|
|
|
|
|
|
expect( el.hasClass( 'foo' ) ).to.true;
|
|
|
expect( el.hasClass( 'bar' ) ).to.true;
|
|
|
@@ -341,7 +341,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should add new class to existing classes', () => {
|
|
|
const el = view.getChild( 1 );
|
|
|
|
|
|
- writer.addClass( el, 'newClass' );
|
|
|
+ writer.addClass( 'newClass', el );
|
|
|
|
|
|
expect( el.hasClass( 'newClass' ) ).to.true;
|
|
|
expect( Array.from( el.getClassNames() ).length ).to.equal( 3 );
|
|
|
@@ -352,7 +352,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should remove existing class', () => {
|
|
|
const el = view.getChild( 3 ).getChild( 0 );
|
|
|
|
|
|
- writer.removeClass( el, 'single' );
|
|
|
+ writer.removeClass( 'single', el );
|
|
|
|
|
|
expect( el.hasClass( 'single' ) ).to.false;
|
|
|
expect( Array.from( el.getClassNames() ).length ).to.equal( 0 );
|
|
|
@@ -361,7 +361,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should remove existing class from many classes', () => {
|
|
|
const el = view.getChild( 1 );
|
|
|
|
|
|
- writer.removeClass( el, 'foo1' );
|
|
|
+ writer.removeClass( 'foo1', el );
|
|
|
|
|
|
expect( el.hasClass( 'foo1' ) ).to.false;
|
|
|
expect( el.hasClass( 'bar2' ) ).to.true;
|
|
|
@@ -371,7 +371,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should have no effect if there are no classes', () => {
|
|
|
const el = view.getChild( 0 );
|
|
|
|
|
|
- writer.removeClass( el, 'non-existent' );
|
|
|
+ writer.removeClass( 'non-existent', el );
|
|
|
|
|
|
expect( el.hasClass( 'non-existent' ) ).to.false;
|
|
|
expect( Array.from( el.getClassNames() ).length ).to.equal( 0 );
|
|
|
@@ -382,10 +382,10 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should add new style', () => {
|
|
|
const el = view.getChild( 2 );
|
|
|
|
|
|
- writer.setStyle( el, {
|
|
|
+ writer.setStyle( {
|
|
|
color: 'red',
|
|
|
position: 'fixed'
|
|
|
- } );
|
|
|
+ }, el );
|
|
|
|
|
|
expect( el.getStyle( 'color' ) ).to.equal( 'red' );
|
|
|
expect( el.getStyle( 'position' ) ).to.equal( 'fixed' );
|
|
|
@@ -395,7 +395,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should update existing styles', () => {
|
|
|
const el = view.getChild( 1 );
|
|
|
|
|
|
- writer.setStyle( el, 'text-align', 'center' );
|
|
|
+ writer.setStyle( 'text-align', 'center', el );
|
|
|
|
|
|
expect( el.getStyle( 'text-align' ) ).to.equal( 'center' );
|
|
|
expect( Array.from( el.getStyleNames() ).length ).to.equal( 1 );
|
|
|
@@ -406,7 +406,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should remove existing style', () => {
|
|
|
const el = view.getChild( 0 );
|
|
|
|
|
|
- writer.removeStyle( el, [ 'color', 'position' ] );
|
|
|
+ writer.removeStyle( [ 'color', 'position' ], el );
|
|
|
|
|
|
expect( el.hasStyle( 'color' ) ).to.false;
|
|
|
expect( el.hasStyle( 'position' ) ).to.false;
|
|
|
@@ -416,7 +416,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should remove value from existing styles', () => {
|
|
|
const el = view.getChild( 0 );
|
|
|
|
|
|
- writer.removeStyle( el, 'position' );
|
|
|
+ writer.removeStyle( 'position', el );
|
|
|
|
|
|
expect( el.hasStyle( 'color' ) ).to.true;
|
|
|
expect( el.hasStyle( 'position' ) ).to.false;
|
|
|
@@ -426,7 +426,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should have no effect if styles does not exists', () => {
|
|
|
const el = view.getChild( 2 );
|
|
|
|
|
|
- writer.removeStyle( el, [ 'color', 'position' ] );
|
|
|
+ writer.removeStyle( [ 'color', 'position' ], el );
|
|
|
|
|
|
expect( el.hasStyle( 'color' ) ).to.false;
|
|
|
expect( el.hasStyle( 'position' ) ).to.false;
|
|
|
@@ -438,15 +438,15 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should add or update custom property', () => {
|
|
|
const el = new Element( 'span' );
|
|
|
|
|
|
- writer.setCustomProperty( el, 'prop1', 'foo' );
|
|
|
- writer.setCustomProperty( el, 'prop2', 'bar' );
|
|
|
+ writer.setCustomProperty( 'prop1', 'foo', el );
|
|
|
+ writer.setCustomProperty( 'prop2', 'bar', el );
|
|
|
|
|
|
expect( el.getCustomProperty( 'prop1' ) ).to.equal( 'foo' );
|
|
|
expect( el.getCustomProperty( 'prop2' ) ).to.equal( 'bar' );
|
|
|
expect( Array.from( el.getCustomProperties() ).length ).to.equal( 2 );
|
|
|
|
|
|
const objectProperty = { foo: 'bar' };
|
|
|
- writer.setCustomProperty( el, 'prop2', objectProperty );
|
|
|
+ writer.setCustomProperty( 'prop2', objectProperty, el );
|
|
|
|
|
|
expect( el.getCustomProperty( 'prop1' ) ).to.equal( 'foo' );
|
|
|
expect( el.getCustomProperty( 'prop2' ) ).to.equal( objectProperty );
|
|
|
@@ -458,12 +458,12 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should remove existing custom property', () => {
|
|
|
const el = new Element( 'p' );
|
|
|
|
|
|
- writer.setCustomProperty( el, 'prop1', 'foo' );
|
|
|
+ writer.setCustomProperty( 'prop1', 'foo', el );
|
|
|
|
|
|
expect( el.getCustomProperty( 'prop1' ) ).to.equal( 'foo' );
|
|
|
expect( Array.from( el.getCustomProperties() ).length ).to.equal( 1 );
|
|
|
|
|
|
- writer.removeCustomProperty( el, 'prop1' );
|
|
|
+ writer.removeCustomProperty( 'prop1', el );
|
|
|
|
|
|
expect( el.getCustomProperty( 'prop1' ) ).to.undefined;
|
|
|
expect( Array.from( el.getCustomProperties() ).length ).to.equal( 0 );
|
|
|
@@ -472,7 +472,7 @@ describe( 'UpcastWriter', () => {
|
|
|
it( 'should have no effect if custom property does not exists', () => {
|
|
|
const el = new Element( 'h1' );
|
|
|
|
|
|
- writer.removeCustomProperty( el, 'prop1' );
|
|
|
+ writer.removeCustomProperty( 'prop1', el );
|
|
|
|
|
|
expect( el.getCustomProperty( 'prop1' ) ).to.undefined;
|
|
|
expect( Array.from( el.getCustomProperties() ).length ).to.equal( 0 );
|