bem-constructor 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df231fc76b0bc8615cc5634a72126ccfb3df62f2
4
- data.tar.gz: 269f157f0874927226870a5dc473d6631dbc0b7e
3
+ metadata.gz: 7b9f377ac2844b2e29439656b8ea795caee5e925
4
+ data.tar.gz: 6522e754bab2703329555864d0edee404cb3e330
5
5
  SHA512:
6
- metadata.gz: 5b39a0af0f8f1452df90ffdf018c661369c19c51e66cfb495e127d824c39092bb1ea8a62b95c562f2cabf9381158e573a722a58a4b221ef5592279731563f67b
7
- data.tar.gz: c5fa49d6e419dc4cb57a570c6e456212dcdf1fce75319458bf8ad8c1c9f08df4ae318a4d6459f75ff05f820c7f2abaa3da0f2643726daccf159a68c3e1970a7d
6
+ metadata.gz: 338df5a582de055c92b5bb917d6673614da3b9708f8781f0b6ddd680db2a1b563abade48e1f2306fb16bdf9ae48e756f318d553c34b95bede1873c9e49bd180e
7
+ data.tar.gz: 347ebc42e58d0a8b9da81cfeb1a5e27fd0b8261a9ff89cff97d3a5bf3e196bda1c2dc467520509d1662d19f9cf4e0051071e8fbcff7627569e4233523e235c66
@@ -3,6 +3,6 @@ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
3
3
  Compass::Frameworks.register('bem-constructor', :path => extension_path)
4
4
 
5
5
  module BEMConstructor
6
- VERSION = "0.3.0"
6
+ VERSION = "0.3.2"
7
7
  DATE = "2015-03-26"
8
8
  end
@@ -23,14 +23,23 @@ $bem-block-namespaces: (
23
23
  $new-block: _bem-log-block($name);
24
24
 
25
25
  // Error check
26
- $outside-check: should-not-be-called-within('scope', 'block');
26
+ $outside-check: _should-not-be-called-within('scope', 'block');
27
+
28
+ // Return false in case error throwing is disabled
29
+ @if $outside-check == false {
30
+ @return false;
31
+ }
27
32
 
28
33
  // Set namespace
29
34
  $namespace: '';
30
35
 
31
36
  @if $bem-use-namespaces {
32
37
  @if not map-has-key($bem-block-namespaces, $type) {
33
- @error '`#{$type}` is not a valid `$type` for `block()`';
38
+ @if $bem-throw-errors {
39
+ @error '`#{$type}` is not a valid `$type` for `block()`';
40
+ }
41
+
42
+ @return false;
34
43
  }
35
44
  $namespace: map-get($bem-block-namespaces, $type) + '-';
36
45
  }
@@ -13,8 +13,13 @@
13
13
  $new-element: _bem-log-element($elements...);
14
14
 
15
15
  // Error checks
16
- $inside-check: should-be-called-within('block');
17
- $outside-check: should-not-be-called-within('modifier', 'state', 'element');
16
+ $inside-check: _should-be-called-within('block');
17
+ $outside-check: _should-not-be-called-within('modifier', 'state', 'element');
18
+
19
+ // Return false in case error throwing is disabled
20
+ @if $inside-check == false or $outside-check == false {
21
+ @return false;
22
+ }
18
23
 
19
24
  $selector: ();
20
25
 
@@ -12,20 +12,13 @@
12
12
  /// Checks that it's being created within all of the passed $objs...
13
13
  @function _should-be-called-within($objs...) {
14
14
 
15
- $found: false;
16
-
17
15
  @each $obj in $objs {
18
- @if map-get($_bem-current-context, $obj) != null {
19
- $found: true;
20
- }
21
- }
22
-
23
- @if not $found {
24
- @if ($bem-throw-error) {
25
- @error 'It should be called within #{inspect($objs)}';
16
+ @if map-get($_bem-current-context, $obj) == null {
17
+ @if $bem-throw-errors {
18
+ @error 'It should be called within #{inspect($objs)}';
19
+ }
20
+ @return false;
26
21
  }
27
-
28
- @return false;
29
22
  }
30
23
 
31
24
  @return true;
@@ -39,19 +32,13 @@
39
32
  /// Checks that it's being created outside all of the passed $objs...
40
33
  @function _should-not-be-called-within($objs...) {
41
34
 
42
- $found: false;
43
-
44
35
  @each $obj in $objs {
45
36
  @if map-get($_bem-current-context, $obj) != null {
46
- $found: true;
47
- }
48
- }
49
-
50
- @if $found {
51
- @if ($bem-throw-error) {
52
- @error 'It should not be called within #{inspect($objs)}';
37
+ @if $bem-throw-errors {
38
+ @error 'It should not be called within #{inspect($objs)}';
39
+ }
40
+ @return false;
53
41
  }
54
- @return false;
55
42
  }
56
43
 
57
44
  @return true;
@@ -10,7 +10,10 @@ $hack-namespace: '_' !default;
10
10
  $parsed: selector-parse($selector);
11
11
 
12
12
  @if length($parsed) > 1 {
13
- @error '`#{$selector}` contains #{length($parsed)} selectors and the `_last-simple-selector()`function accepts only 1.';
13
+ @if $bem-throw-errors {
14
+ @error '`#{$selector}` contains #{length($parsed)} selectors and the `_last-simple-selector()`function accepts only 1.';
15
+ }
16
+ @return false;
14
17
  }
15
18
  $last-simple-selector: nth(nth($parsed, 1), -1);
16
19
 
@@ -17,6 +17,11 @@
17
17
  $inside-check: _should-be-called-within('block');
18
18
  $outside-check: _should-not-be-called-within('modifier');
19
19
 
20
+ // Return false in case error throwing is disabled
21
+ @if $inside-check == false or $outside-check == false {
22
+ @return false;
23
+ }
24
+
20
25
  $selector: ();
21
26
 
22
27
  @each $modifier in $modifiers {
@@ -9,8 +9,12 @@
9
9
 
10
10
  @function _modifies-element($modified-elements...) {
11
11
 
12
- $inside-check: should-be-called-within('modifier', 'state');
13
- $outside-check: should-not-be-called-within('element');
12
+ $inside-check: _should-be-called-within('modifier', 'state');
13
+ $outside-check: _should-not-be-called-within('element');
14
+
15
+ @if $inside-check == 'false' or $outside-check == false {
16
+ @return false;
17
+ }
14
18
 
15
19
  $selectors: ();
16
20
 
@@ -16,7 +16,10 @@
16
16
 
17
17
  // Check if the block has already been created
18
18
  @if block-exists($block) {
19
- @error '`#{$block}` block has already been created';
19
+ @if $bem-throw-errors {
20
+ @error '`#{$block}` block has already been created';
21
+ }
22
+ @return false;
20
23
  }
21
24
 
22
25
  // Initialize a new block map
@@ -31,7 +31,11 @@
31
31
 
32
32
  // Check any $elements has already been defined for the current block
33
33
  @if element-exists($elements...) {
34
- @error 'One or more elements from `#{inspect($elements)}` have already been created';
34
+ @if $bem-throw-errors {
35
+ @error 'One or more elements from `#{inspect($elements)}` have already been created';
36
+ }
37
+
38
+ @return false;
35
39
  }
36
40
 
37
41
  // Find the current block name
@@ -31,7 +31,11 @@
31
31
 
32
32
  // Check if the modifier has already been defined for the current block or element
33
33
  @if modifier-exists($modifiers...) {
34
- @error 'One or more elements from `#{inspect($modifiers)}` have already been created';
34
+ @if $bem-throw-errors {
35
+ @error 'One or more elements from `#{inspect($modifiers)}` have already been created';
36
+ }
37
+
38
+ @return false;
35
39
  }
36
40
 
37
41
  // Find the current block name
@@ -16,7 +16,11 @@
16
16
 
17
17
  // Check if the scope has already been created
18
18
  @if scope-exists($scope) {
19
- @error '`#{$scope}` scope has already been created';
19
+ @if $bem-throw-errors {
20
+ @error '`#{$scope}` scope has already been created';
21
+ }
22
+
23
+ @return false;
20
24
  }
21
25
 
22
26
  // Initialize a new scope map
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bem-constructor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Guillan