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

mustDeps from own modifier is impossible #148

Closed
tadatuta opened this issue Apr 25, 2015 · 9 comments · Fixed by #149
Closed

mustDeps from own modifier is impossible #148

tadatuta opened this issue Apr 25, 2015 · 9 comments · Fixed by #149
Assignees
Labels
Milestone

Comments

@tadatuta
Copy link
Member

Looks like it's impossible now to have mustDeps from own modifier:

$ ls common.blocks/b1/
b1.deps.js

$ cat common.blocks/b1/b1.deps.js
({
    mustDeps: [
        {
            mods:  { m1: 'v1' }
        }
    ]
})

$ enb make
# ...
Error: Unresolved deps:
b1 <- b1_m1_v1
b1_m1_v1 <- b1, b1_m1
b1_m1 <- b1

// cc @blond @incrop

@tadatuta tadatuta added the bug label Apr 25, 2015
@tadatuta tadatuta added this to the 1.0.5 milestone Apr 25, 2015
@tadatuta
Copy link
Member Author

BTW,

({
    mustDeps: [
        { elems:  ['e1'] }
    ]
})

works fine.

@incrop
Copy link

incrop commented Apr 26, 2015

@tadatuta I think this is not a bug, you have a circular mustDeps issue here.
Modifier should modify the block, therefore block must be declared before its mods.
In deps tech this is enforced by adding block to mustDeps for mod. This is how it always worked (check this commit from 2013).
Noteworthy, deps-old tech allows you to have mustDeps from own modifier.

@tadatuta
Copy link
Member Author

I understand the idea but still I used to use such possibility with deps-old at least for 2 reasons:

  1. To override some styles of a _theme from a library on project level. It's quite safe when you know what you're doing as most likely there's no CSS for block without theme modifier.
  2. To set some defaults for non-BEM modules. E.g. in m1_lang_ru.js:
m1.defaults.lang.ru = {/* ... */};

And then I can initiate an instance of m1 in m1.js.

Both of the cases are quite ugly but still they were possible when really needed.

@Guria
Copy link

Guria commented Apr 27, 2015

+1, I don't like an implicit deps from block.

@tadatuta
Copy link
Member Author

I asked @veged, he agrees that it's a bug

@blond blond self-assigned this Apr 27, 2015
@blond
Copy link
Member

blond commented Apr 27, 2015

@tadatuta Looks really like a bug. The question is whether you can fix it without breaking habitual behavior.

@blond
Copy link
Member

blond commented Apr 27, 2015

This problem is also relevant for elem mods:

({
    mustDeps: [
        {
            elem: 'e1', mods:  { m1: 'v1' }
        }
    ]
})
Error: Unresolved deps: 
b1__e1 <- b1__e1_m1_v1
b1__e1_m1_v1 <- b1__e1, b1__e1_m1
b1__e1_m1 <- b1__e1

@Guria
Copy link

Guria commented Apr 27, 2015

is bem-site/bem-forum-content-ru#182 relevant to this issue?

@blond
Copy link
Member

blond commented Apr 27, 2015

@Guria, I think that this is another problem.

@blond blond closed this as completed in #149 May 5, 2015
@blond blond modified the milestones: 1.0.5, 2.0 Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants