Sha256: eed200988d909f8096a8b29a6885a7dbb70a69ec3198fe31f0862e35dc5f9011

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 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');

    $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

4 entries across 4 versions & 1 rubygems

Version Path
bem-constructor-0.3.0 stylesheets/_element.scss
bem-constructor-0.2.0 stylesheets/_element.scss
bem-constructor-0.1.1 stylesheets/_element.scss
bem-constructor-0.1 stylesheets/_element.scss