Sha256: 44b81a8541a0ae842729d74930451fc130e7834e345b90e583acab9d956977f7

Contents?: true

Size: 1.32 KB

Versions: 9

Compression:

Stored size: 1.32 KB

Contents

// ----------------------------------------------------------------------
// Element constructor
// ----------------------------------------------------------------------

/// Initializes a new element for the current block
/// @private
/// @param {String | Arglist} $elements - List of new element names
/// @returns The final selector for the new element(s)

@function _element($elements...) {

    // Log new element(s)
    $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');

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

    $selector: ();

    @each $element in $elements {
        $e: #{&}#{$bem-element-separator}#{$element};
        $selector: append($selector, $e, 'comma');
    }

    $set-current: set-current-context('element', $elements, $selector);

    @return $selector;
}


/// Creates new element(s)
/// @param {String | Arglist} $elements  - Name of the new element(s)

@mixin element($elements...) {

    @at-root #{_element($elements...)} {
        @content;
    }

    // Clear $_bem-current-context element after creation
    $unset-current: unset-current-context('element');
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bem-constructor-1.0.0 stylesheets/_element.scss
bem-constructor-0.9.0 stylesheets/_element.scss
bem-constructor-0.8.0 stylesheets/_element.scss
bem-constructor-0.7.1 stylesheets/_element.scss
bem-constructor-0.7.0 stylesheets/_element.scss
bem-constructor-0.6.0 stylesheets/_element.scss
bem-constructor-0.5.0 stylesheets/_element.scss
bem-constructor-0.4.0 stylesheets/_element.scss
bem-constructor-0.3.2 stylesheets/_element.scss