Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 48cd53d

Browse files
authored
Merge pull request #382 from ckeditor/t/ckeditor5/742
Other: Renamed plural method names to singular. See ckeditor/ckeditor5#742. BREAKING CHANGES: `View#registerChildren()` and `View#deregisterChildren()` have been renamed to `View#registerChild()` and `View#deregisterChild()`.
2 parents 7d88f9e + a4095ac commit 48cd53d

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/view.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import '../theme/globals/globals.css';
2323
* {@link module:ui/view~View#template}. Views are building blocks of the user interface and handle
2424
* interaction
2525
*
26-
* Views {@link module:ui/view~View#registerChildren aggregate} children in
26+
* Views {@link module:ui/view~View#registerChild aggregate} children in
2727
* {@link module:ui/view~View#createCollection collections} and manage the life cycle of DOM
2828
* listeners e.g. by handling rendering and destruction.
2929
*
@@ -291,7 +291,7 @@ export default class View {
291291
* view is managed by its parent, including {@link #render rendering}
292292
* and {@link #destroy destruction}.
293293
*
294-
* To revert this, use {@link #deregisterChildren}.
294+
* To revert this, use {@link #deregisterChild}.
295295
*
296296
* class SampleView extends View {
297297
* constructor( locale ) {
@@ -303,7 +303,7 @@ export default class View {
303303
* this.setTemplate( { tag: 'p' } );
304304
*
305305
* // Register the children.
306-
* this.registerChildren( [ this.childA, this.childB ] );
306+
* this.registerChild( [ this.childA, this.childB ] );
307307
* }
308308
*
309309
* render() {
@@ -335,7 +335,7 @@ export default class View {
335335
* tag: 'p',
336336
*
337337
* // These children will be added automatically. There's no
338-
* // need to call {@link #registerChildren} for any of them.
338+
* // need to call {@link #registerChild} for any of them.
339339
* children: [ this.childA, this.childB ]
340340
* } );
341341
* }
@@ -345,7 +345,7 @@ export default class View {
345345
*
346346
* @param {module:ui/view~View|Iterable.<module:ui/view~View>} children Children views to be registered.
347347
*/
348-
registerChildren( children ) {
348+
registerChild( children ) {
349349
if ( !isIterable( children ) ) {
350350
children = [ children ];
351351
}
@@ -356,14 +356,14 @@ export default class View {
356356
}
357357

358358
/**
359-
* The opposite of {@link #registerChildren}. Removes a child view from this view instance.
359+
* The opposite of {@link #registerChild}. Removes a child view from this view instance.
360360
* Once removed, the child is no longer managed by its parent, e.g. it can safely
361361
* become a child of another parent view.
362362
*
363-
* @see #registerChildren
363+
* @see #registerChild
364364
* @param {module:ui/view~View|Iterable.<module:ui/view~View>} children Child views to be removed.
365365
*/
366-
deregisterChildren( children ) {
366+
deregisterChild( children ) {
367367
if ( !isIterable( children ) ) {
368368
children = [ children ];
369369
}
@@ -413,7 +413,7 @@ export default class View {
413413
* **Note**: The children of the view:
414414
* * defined directly in the {@link #template}
415415
* * residing in collections created by the {@link #createCollection} method,
416-
* * and added by {@link #registerChildren}
416+
* * and added by {@link #registerChild}
417417
* are also rendered in the process.
418418
*
419419
* In general, `render()` method is the right place to keep the code which refers to the
@@ -475,14 +475,14 @@ export default class View {
475475
this.element = this.template.render();
476476

477477
// Auto–register view children from #template.
478-
this.registerChildren( this.template.getViews() );
478+
this.registerChild( this.template.getViews() );
479479
}
480480

481481
this.isRendered = true;
482482
}
483483

484484
/**
485-
* Recursively destroys the view instance and child views added by {@link #registerChildren} and
485+
* Recursively destroys the view instance and child views added by {@link #registerChild} and
486486
* residing in collections created by the {@link #createCollection}.
487487
*
488488
* Destruction disables all event listeners:

tests/view.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe( 'View', () => {
9090
} );
9191
} );
9292

93-
describe( 'registerChildren()', () => {
93+
describe( 'registerChild()', () => {
9494
beforeEach( () => {
9595
setTestViewClass();
9696
setTestViewInstance();
@@ -101,20 +101,20 @@ describe( 'View', () => {
101101

102102
const child = new View();
103103

104-
view.registerChildren( child );
104+
view.registerChild( child );
105105
expect( view._unboundChildren ).to.have.length( 1 );
106106
expect( view._unboundChildren.get( 0 ) ).to.equal( child );
107107
} );
108108

109109
it( 'should support iterables', () => {
110110
expect( view._unboundChildren ).to.have.length( 0 );
111111

112-
view.registerChildren( [ new View(), new View(), new View() ] );
112+
view.registerChild( [ new View(), new View(), new View() ] );
113113
expect( view._unboundChildren ).to.have.length( 3 );
114114
} );
115115
} );
116116

117-
describe( 'deregisterChildren()', () => {
117+
describe( 'deregisterChild()', () => {
118118
beforeEach( () => {
119119
setTestViewClass();
120120
setTestViewInstance();
@@ -124,11 +124,11 @@ describe( 'View', () => {
124124
const child1 = new View();
125125
const child2 = new View();
126126

127-
view.registerChildren( child1 );
128-
view.registerChildren( child2 );
127+
view.registerChild( child1 );
128+
view.registerChild( child2 );
129129
expect( view._unboundChildren ).to.have.length( 2 );
130130

131-
view.deregisterChildren( child2 );
131+
view.deregisterChild( child2 );
132132
expect( view._unboundChildren ).to.have.length( 1 );
133133
expect( view._unboundChildren.get( 0 ) ).to.equal( child1 );
134134
} );
@@ -138,10 +138,10 @@ describe( 'View', () => {
138138
const child2 = new View();
139139
const child3 = new View();
140140

141-
view.registerChildren( [ child1, child2, child3 ] );
141+
view.registerChild( [ child1, child2, child3 ] );
142142
expect( view._unboundChildren ).to.have.length( 3 );
143143

144-
view.deregisterChildren( [ child2, child3 ] );
144+
view.deregisterChild( [ child2, child3 ] );
145145
expect( view._unboundChildren ).to.have.length( 1 );
146146
expect( view._unboundChildren.get( 0 ) ).to.equal( child1 );
147147
} );
@@ -343,7 +343,7 @@ describe( 'View', () => {
343343
it( 'should not clear the #_unboundChildren', () => {
344344
const cached = view._unboundChildren;
345345

346-
view.registerChildren( [ new View(), new View() ] );
346+
view.registerChild( [ new View(), new View() ] );
347347
expect( cached ).to.have.length( 4 );
348348

349349
view.destroy();

0 commit comments

Comments
 (0)