Skip to content

Namespaces with guards #1812

Closed
Closed

Description

@SomMeri

Guards on namespaces are ignored. Following less:

@variable:2;
#namespace when (@variable=1){
  .mixin() {
    false: guard;
  }
}

#use-place {
  #namespace > .mixin();
}

compiles into:

#use-place {
  false: guard;
}

Expected result:

<empty css>

I think that it is related to #1525. It is almost the same problem - namespace with foreign syntax on it. So, the solution could be exactly the same: ignore namespace with guard (whether satisfied or not).

Activity

  1. lukeapage commented on Feb 23, 2014

    @lukeapage
    Member

    I don't think its a bug

    its just a css selector with a guard on it e.g.

    @variable:2;
    .namespace when (@variable=1){
      .mixin() {
        false: guard;
      }
    }
    
    #use-place {
      .namespace > .mixin();
    }
    

    which also gives the same output as...

    @variable:2;
    .namespace() when (@variable=1){
      .mixin() {
        false: guard;
      }
    }
    .namespace();
    
    #use-place {
      .namespace > .mixin();
    }
    

    possibly that last example is a bug.

    But yes I would say we just can't use guards like this.

  2. seven-phases-max commented on Feb 23, 2014

    @seven-phases-max
    Member

    I think ideally we would need to throw a error on #ns > .mixin() if #ns is parametric or has guards... But that's ideally (assuming it's quite minor issue so far, so it would make sense to declare both as "not quite officially supported". Otherwise we would have to add guard test into the mixin match search (not that easy, minus perf.) and allow #ns(parameters...) > .mixin() which is yet another big story).

  3. SomMeri commented on Feb 23, 2014

    @SomMeri
    MemberAuthor

    @seven-phases-max #ns(parameters...) > .mixin() sounds like a cool feature :). Not sure how useful it would be through.

  4. lukeapage commented on Feb 23, 2014

    @lukeapage
    Member

    I agree an error or just skipping (maybe skipping all () mixins and
    skipping selectors on guards that fail) would make more sense.

  5. SomMeri commented on Feb 24, 2014

    @SomMeri
    MemberAuthor

    If they are skipped, then we can not add this feature inside later on without breaking existing sheets. So, error might be more future safe.

  6. SomMeri commented on Feb 24, 2014

    @SomMeri
    MemberAuthor

    I hit comment too soon, edited clearer version.

    If namespaces with guards are skipped, then we can not add support for them later on without breaking existing sheets. So, error might be more future safe.

    Namespaces with parameters would be more user friendly if they are simply skipped, there is no reason not to allow them. Even if such support would added later on, it would break nothing.

  7. lukeapage commented on Feb 24, 2014

    @lukeapage
    Member

    When I said skip, I meant skip if the condition fails.. but actually we
    dont know if the condition passes at the mixin call stage, so probably an
    error is better.

  8. SomMeri commented on Feb 24, 2014

    @SomMeri
    MemberAuthor

    Is it difficult to test the condition at that stage? I'm just curious. The namespace have to be compiled before looking for mixins in it (because of import mixin feature) anyway.

  9. seven-phases-max commented on Feb 24, 2014

    @seven-phases-max
    Member

    I guess the main problem is that mixins are expanded before variables are evaluated (because mixin expansion can bring a new variable into the scope (or override existing one)). That's why we also have a few issues with variables not always working when using interpolated selectors as mixins (i.e. now we have mixins affecting variables and variables affecting mixins -> cycle dependencies).

  10. lukeapage commented on Feb 24, 2014

    @lukeapage
    Member

    exactly. and this is also why imports with variables only work in an extremely limited way

  11. SomMeri commented on Sep 7, 2014

    @SomMeri
    MemberAuthor

    Closing this since it was fixed by #2180 and will go into v2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions