Skip to content

Commit

Permalink
Bump version 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
danielguillan committed Mar 26, 2015
1 parent 1bd472f commit d564da7
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 37 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bem-constructor",
"version": "0.3.1",
"version": "0.3.2",
"main": "dist/_bem-constructor.scss",
"author": "Daniel Guillan",
"ignore": ["*","!dist/_bem-constructor.scss"]
Expand Down
96 changes: 62 additions & 34 deletions dist/_bem-constructor.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! bem-constructor - v0.3.0 - 2015-03-26 */
/*! bem-constructor - v0.3.2 - 2015-03-26 */
// -----------------------------------------------------------------------------
// Defaults
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -85,7 +85,10 @@ $_bem-current-context: () !global;

// Check if the block has already been created
@if block-exists($block) {
@error '`#{$block}` block has already been created';
@if $bem-throw-errors {
@error '`#{$block}` block has already been created';
}
@return false;
}

// Initialize a new block map
Expand Down Expand Up @@ -131,7 +134,11 @@ $_bem-current-context: () !global;

// Check any $elements has already been defined for the current block
@if element-exists($elements...) {
@error 'One or more elements from `#{inspect($elements)}` have already been created';
@if $bem-throw-errors {
@error 'One or more elements from `#{inspect($elements)}` have already been created';
}

@return false;
}

// Find the current block name
Expand Down Expand Up @@ -191,7 +198,11 @@ $_bem-current-context: () !global;

// Check if the modifier has already been defined for the current block or element
@if modifier-exists($modifiers...) {
@error 'One or more elements from `#{inspect($modifiers)}` have already been created';
@if $bem-throw-errors {
@error 'One or more elements from `#{inspect($modifiers)}` have already been created';
}

@return false;
}

// Find the current block name
Expand Down Expand Up @@ -271,7 +282,11 @@ $_bem-current-context: () !global;

// Check if the scope has already been created
@if scope-exists($scope) {
@error '`#{$scope}` scope has already been created';
@if $bem-throw-errors {
@error '`#{$scope}` scope has already been created';
}

@return false;
}

// Initialize a new scope map
Expand All @@ -298,20 +313,13 @@ $_bem-current-context: () !global;
/// Checks that it's being created within all of the passed $objs...
@function _should-be-called-within($objs...) {

$found: false;

@each $obj in $objs {
@if map-get($_bem-current-context, $obj) != null {
$found: true;
}
}

@if not $found {
@if ($bem-throw-error) {
@error 'It should be called within #{inspect($objs)}';
@if map-get($_bem-current-context, $obj) == null {
@if $bem-throw-errors {
@error 'It should be called within #{inspect($objs)}';
}
@return false;
}

@return false;
}

@return true;
Expand All @@ -325,21 +333,15 @@ $_bem-current-context: () !global;
/// Checks that it's being created outside all of the passed $objs...
@function _should-not-be-called-within($objs...) {

$found: false;

@each $obj in $objs {
@if map-get($_bem-current-context, $obj) != null {
$found: true;
@if $bem-throw-errors {
@error 'It should not be called within #{inspect($objs)}';
}
@return false;
}
}

@if $found {
@if ($bem-throw-error) {
@error 'It should not be called within #{inspect($objs)}';
}
@return false;
}

@return true;
}

Expand Down Expand Up @@ -368,14 +370,23 @@ $bem-block-namespaces: (
$new-block: _bem-log-block($name);

// Error check
$outside-check: should-not-be-called-within('scope', 'block');
$outside-check: _should-not-be-called-within('scope', 'block');

// Return false in case error throwing is disabled
@if $outside-check == false {
@return false;
}

// Set namespace
$namespace: '';

@if $bem-use-namespaces {
@if not map-has-key($bem-block-namespaces, $type) {
@error '`#{$type}` is not a valid `$type` for `block()`';
@if $bem-throw-errors {
@error '`#{$type}` is not a valid `$type` for `block()`';
}

@return false;
}
$namespace: map-get($bem-block-namespaces, $type) + '-';
}
Expand Down Expand Up @@ -450,8 +461,13 @@ $bem-block-namespaces: (
$new-element: _bem-log-element($elements...);

// Error checks
$inside-check: should-be-called-within('block');
$outside-check: should-not-be-called-within('modifier', 'state', 'element');
$inside-check: _should-be-called-within('block');
$outside-check: _should-not-be-called-within('modifier', 'state', 'element');

// Return false in case error throwing is disabled
@if $inside-check == false or $outside-check == false {
@return false;
}

$selector: ();

Expand Down Expand Up @@ -498,6 +514,11 @@ $bem-block-namespaces: (
$inside-check: _should-be-called-within('block');
$outside-check: _should-not-be-called-within('modifier');

// Return false in case error throwing is disabled
@if $inside-check == false or $outside-check == false {
@return false;
}

$selector: ();

@each $modifier in $modifiers {
Expand Down Expand Up @@ -540,8 +561,12 @@ $bem-block-namespaces: (

@function _modifies-element($modified-elements...) {

$inside-check: should-be-called-within('modifier', 'state');
$outside-check: should-not-be-called-within('element');
$inside-check: _should-be-called-within('modifier', 'state');
$outside-check: _should-not-be-called-within('element');

@if $inside-check == 'false' or $outside-check == false {
@return false;
}

$selectors: ();

Expand Down Expand Up @@ -687,7 +712,10 @@ $hack-namespace: '_' !default;
$parsed: selector-parse($selector);

@if length($parsed) > 1 {
@error '`#{$selector}` contains #{length($parsed)} selectors and the `_last-simple-selector()`function accepts only 1.';
@if $bem-throw-errors {
@error '`#{$selector}` contains #{length($parsed)} selectors and the `_last-simple-selector()`function accepts only 1.';
}
@return false;
}
$last-simple-selector: nth(nth($parsed, 1), -1);

Expand Down
2 changes: 1 addition & 1 deletion lib/bem-constructor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
Compass::Frameworks.register('bem-constructor', :path => extension_path)

module BEMConstructor
VERSION = "0.3.1"
VERSION = "0.3.2"
DATE = "2015-03-26"
end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bem-constructor",
"author": "Daniel Guillan",
"version": "0.3.1",
"version": "0.3.2",
"scripts": {
"test": "grunt test"
},
Expand Down

0 comments on commit d564da7

Please sign in to comment.