This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Conversation
…ing multiple items to Collection#add().
…dded to the Collection.
jodator
suggested changes
Oct 30, 2019
Contributor
jodator
left a comment
There was a problem hiding this comment.
Minor R- because of code style and wording.
Also, I'd remove double assignment in _getItemIdBeforeAdding() but TBH it's not a big deal.
| const idProperty = this._idProperty; | ||
| let itemId; | ||
|
|
||
| if ( ( idProperty in item ) ) { |
|
|
||
| if ( typeof itemId != 'string' ) { | ||
| /** | ||
| * This item's id should be a string. |
Contributor
There was a problem hiding this comment.
Suggested change
| * This item's id should be a string. | |
| * This item's id must be a string. |
| } ); | ||
| } | ||
| } else { | ||
| item[ idProperty ] = itemId = uid(); |
Contributor
There was a problem hiding this comment.
I'm not a fan of double assignments. Maybe move the itemId to the first if and always return item[ idProperty ]?
| * @param {Object} item | ||
| * @param {Number} [index] The position of the item in the collection. The item | ||
| * is pushed to the collection when `index` not specified. | ||
| * @param {...(Object)} items Item or items to be added to the collection. |
Contributor
There was a problem hiding this comment.
Suggested change
| * @param {...(Object)} items Item or items to be added to the collection. | |
| * @param {...Object} items Item or items to be added to the collection. |
mlewand
reviewed
Feb 19, 2020
| constructor( initialItemsOrOptions = {}, options = {} ) { | ||
| let initialItems = []; | ||
|
|
||
| if ( initialItemsOrOptions instanceof Array ) { |
Contributor
There was a problem hiding this comment.
I'd like to see constructor accepting more generic, Iterable compliant values. This would allow using Sets too.
mlewand
added a commit
to ckeditor/ckeditor5-ui
that referenced
this pull request
Feb 19, 2020
…ion. Ported changes from ckeditor/ckeditor5-utils#309 (1aac49db1ca9ea914f9fc44f00e295474faf3ed2). Note this breaks BodyCollection integration, so there's more work to be done.
panr
pushed a commit
to ckeditor/ckeditor5-ui
that referenced
this pull request
Apr 7, 2020
…ion. Ported changes from ckeditor/ckeditor5-utils#309 (1aac49db1ca9ea914f9fc44f00e295474faf3ed2). Note this breaks BodyCollection integration, so there's more work to be done.
mlewand
added a commit
to ckeditor/ckeditor5
that referenced
this pull request
May 1, 2020
…ion. Ported changes from ckeditor/ckeditor5-utils#309 (1aac49db1ca9ea914f9fc44f00e295474faf3ed2). Note this breaks BodyCollection integration, so there's more work to be done.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suggested merge commit message (convention)
Feature: Added support for creating a
Collectionwith initial items and supplying multiple items toCollection#add()(see ckeditor/ckeditor5#4992).Other PRs:
CI
Couldn't find more use–cases but perhaps there are some that could benefit from the new API.