Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand method in import-notation #288

Closed
wants to merge 4 commits into from

Conversation

Vittly
Copy link
Collaborator

@Vittly Vittly commented Mar 10, 2018

Fixing #275.

Also fixed part about "exclude" logic of ctx in parse method (don't know am I right or not). Excluding makes sense only if block requires its modifiers. But I have no real example when it is done. Usually we require modifiers from other blocks and than we need a block too.

@Vittly Vittly force-pushed the refactor-import-notation branch 2 times, most recently from 25d60fb to 16f3739 Compare March 10, 2018 06:52
@Vittly
Copy link
Collaborator Author

Vittly commented Mar 10, 2018

@Yeti-or @zxqfox come to check please

@Vittly Vittly force-pushed the refactor-import-notation branch from 16f3739 to 550bbbf Compare March 12, 2018 09:37
Example:

```js
var notation = parse('e:text', { block: 'button' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expand?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I didn't understand the difference from parse method.
Actually, I understood but it was not so obvious
add examples of the distinction between them, please

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need 2 methods? ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! expand gives us string and it is fast/lightweight

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure expand is the most viable name for this functionality?

I'd suggest:

  • fullfill
  • fillup
  • sate

@@ -1,23 +1,7 @@
const hashSet = require('hash-set');
const helpers = require('./lib/helpers');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to package.json

main.block = ctx.block;
main.elem || ctx.elem && (main.elem = ctx.elem);
}
switch(type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why switch here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not?


describe('elem', () => {
it('should copy elem if notation has no elem', () => {
expect(e('m:theme=default', { block : 'button', elem : 'icon' })).to.eql('b:button e:icon m:theme=default');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a test for block_mod too

('m:theme=default', { block : 'button' })

@@ -70,19 +70,22 @@ describe('block', () => {
describe('context is block', () => {
it('should extract blockMod', () => {
expect(p('m:autoclosable', { block : 'popup' })).to.eql([
{ block : 'popup' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was here on purpose, so it's not a patch
but since we have a problem with natural dependency in webpack-bem-loader/babel-plugin-bem-import: bem/webpack-bem-loader#64
maybe we should fix it here.
Need a discussion.
And maybe separate pr. Is it possible @Vittly ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made separate pr: #289

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, okey I'll do it after adding expand

modVals = splitMod[1];
case 'e':
cell.elem = tail;
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is strange

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add more details?

Copy link
Member

@qfox qfox Mar 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry. we mutating cell but not adding it to acc. For the rest types we call acc.add one or more times.

/**
* Helpers to test import-notation first part
*/
const tests = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this object. Prob it's enough to make 2 simple functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it a group of functions like templates object after

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, not a blocker.

main.elem || ctx.elem && (main.elem = ctx.elem);
}
switch(type) {
case 'b':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже не любишь делать доп отступ для case? ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vasiliy не любит =)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, it's O2 team code style.

@Vittly Vittly closed this May 6, 2018
@Vittly
Copy link
Collaborator Author

Vittly commented May 6, 2018

closed in favor of #312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants