Sha256: ea2da1fa4766a8f42ac399ffe584c88bd7c37d32c19c2487ac57783b66fe44bb

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

// -----------------------------------------------------------------------------
// Error checks
// -----------------------------------------------------------------------------
// Table of contents:
// 1. Within
// 2. Outside

// -----------------------------------------------------------------------------
// 1. Within
// -----------------------------------------------------------------------------

/// 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)}';
        }

        @return false;
    }

    @return true;
}


// -----------------------------------------------------------------------------
// 2. Outside
// -----------------------------------------------------------------------------

/// 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 $found {
        @if ($bem-throw-error) {
            @error 'It should not be called within #{inspect($objs)}';
        }
        @return false;
    }

    @return true;
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bem-constructor-0.3.0 stylesheets/_error-checks.scss
bem-constructor-0.2.0 stylesheets/_error-checks.scss