FindChildBlock throws an Error if Block given as string#1469
Merged
Conversation
Member
|
@skad0 should also throw on |
narqo
reviewed
Jan 25, 2017
common.blocks/i-bem-dom/i-bem-dom.js
Outdated
| findChildBlock : function(Block) { | ||
| // TODO: throw if Block passed as a string | ||
| if(typeof Block === 'string') { | ||
| throw new Error('Block can\'t be a String'); |
Member
There was a problem hiding this comment.
The message which describes what type Block is allowed to be, might be more useful in case of error. Consider "Block must be a class or an instance", as an example.
Contributor
Author
|
🆙 |
Member
|
cc @dfilatov |
Member
|
8df32d2 to
bf77793
Compare
bf77793 to
38f10e4
Compare
38f10e4 to
57f78c0
Compare
Contributor
Author
|
🆙 |
Member
|
lgtm |
birhoff
requested changes
Feb 26, 2017
| typeof Block === 'string' || | ||
| typeof Block === 'object' && typeof Block.block === 'string' | ||
| ) { | ||
| throw new Error('Block must be a class or description (block, modName, modVal) of the block to find'); |
There was a problem hiding this comment.
- i still can pass primitives numbers, boolean, undefined
- any function
error message of this validation and validation description don't fit with code.
| // TODO: throw if Block passed as a string | ||
| validateBlockParam(Block); | ||
|
|
||
| return this._findEntities('find', Block, true); |
There was a problem hiding this comment.
Why we don't do this check at _findEntities ?
Member
There was a problem hiding this comment.
'cos _findEntities is also used for elements passed as strings
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Referred to this
@tadatuta