fela-dom
Version:
Fela package for working with the DOM
21 lines (18 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = createStyleTagMarkup;
var _fastLoops = require("fast-loops");
function createStyleTagMarkup(css, type) {
var media = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var rehydrationIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
var support = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var styleNodeAttributes = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
var mediaAttribute = media.length > 0 ? " media=\"".concat(media, "\"") : '';
var supportAttribute = support ? ' data-fela-support="true"' : '';
var userAttributes = (0, _fastLoops.objectReduce)(styleNodeAttributes, function (attributes, value, attribute) {
return attributes + ' ' + attribute + '="' + value + '"';
}, '');
return "<style type=\"text/css\" data-fela-rehydration=\"".concat(rehydrationIndex, "\" data-fela-type=\"").concat(type, "\"").concat(supportAttribute).concat(mediaAttribute).concat(userAttributes, ">").concat(css, "</style>");
}