Blame view

node_modules/less/test/less-bom/scope.less 1.7 KB
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  @x: red;
  @x: blue;
  @z: transparent;
  @mix: none;
  
  .mixin {
    @mix: #989;
  }
  @mix: blue;
  .tiny-scope {
    color: @mix; // #989
    .mixin;
  }
  
  .scope1 {
    @y: orange;
    @z: black;
    color: @x; // blue
    border-color: @z; // black
    .hidden {
      @x: #131313;
    }
    .scope2 {
      @y: red;
      color: @x; // blue
      .scope3 {
        @local: white;
        color: @y; // red
        border-color: @z; // black
        background-color: @local; // white
      }
    }
  }
  
  #namespace {
    .scoped_mixin() {
      @local-will-be-made-global: green;
      .scope {
        scoped-val: @local-will-be-made-global;
      }
    }
  }
  
  #namespace > .scoped_mixin();
  
  .setHeight(@h) { @height: 1024px; }
  .useHeightInMixinCall(@h) { .useHeightInMixinCall { mixin-height: @h; } }
  @mainHeight: 50%;
  .setHeight(@mainHeight);
  .heightIsSet { height: @height; }
  .useHeightInMixinCall(@height);
  
  .importRuleset() {
    .imported {
      exists: true;
    }
  }
  .importRuleset();
  .testImported {
    .imported;
  }
  
  @parameterDefault: 'top level';
  @anotherVariable: 'top level';
  //mixin uses top-level variables
  .mixinNoParam(@parameter: @parameterDefault) when (@parameter = 'top level') {
    default: @parameter;
    scope: @anotherVariable;
    sub-scope-only: @subScopeOnly;
  }
  
  #allAreUsedHere {
    //redefine top-level variables in different scope
    @parameterDefault: 'inside';
    @anotherVariable: 'inside';
    @subScopeOnly: 'inside';
    //use the mixin
    .mixinNoParam();
  }
  #parentSelectorScope {
    @col: white;
    & {
      @col: black;
    }
    prop: @col;
    & {
      @col: black;
    }
  }
  .test-empty-mixin() {
  }
  #parentSelectorScopeMixins {
    & {
      .test-empty-mixin() {
        should: never seee 1;
      }
    }
    .test-empty-mixin();
    & {
      .test-empty-mixin() {
        should: never seee 2;
      }
    }
  }