Comparing version 11.1.2 to 11.2.0
@@ -0,1 +1,3 @@ | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
@@ -10,2 +12,3 @@ | ||
var sortMediaQuery = arguments[2]; | ||
var styleNodeAttributes = arguments[3]; | ||
@@ -30,2 +33,14 @@ var head = targetDocument.head || {}; | ||
// applying custom style tag attributes | ||
for (var attribute in styleNodeAttributes) { | ||
node.setAttribute(attribute, styleNodeAttributes[attribute]); | ||
} | ||
// also apply attributes set globally with window.FelaConfig | ||
if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) !== undefined && window.FelaConfig) { | ||
for (var _attribute in window.FelaConfig.styleNodeAttributes) { | ||
node.setAttribute(_attribute, window.FelaConfig.styleNodeAttributes[_attribute]); | ||
} | ||
} | ||
var nodes = head.querySelectorAll('[data-fela-type]'); | ||
@@ -32,0 +47,0 @@ var sibling = getNodeSibling([].concat(_toConsumableArray(nodes)), attributes, sortMediaQuery); |
@@ -20,3 +20,3 @@ import queryNode from './queryNode'; | ||
if (!renderer.nodes[reference]) { | ||
var node = queryNode(attributes, targetDocument) || createNode(attributes, targetDocument, renderer.sortMediaQuery); | ||
var node = queryNode(attributes, targetDocument) || createNode(attributes, targetDocument, renderer.sortMediaQuery, renderer.styleNodeAttributes); | ||
@@ -23,0 +23,0 @@ renderer.nodes[reference] = node; |
@@ -0,3 +1,3 @@ | ||
import objectReduce from 'fast-loops/lib/objectReduce'; | ||
export default function createStyleTagMarkup(css, type) { | ||
@@ -7,7 +7,11 @@ var media = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
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="' + media + '"' : ''; | ||
var supportAttribute = support ? ' data-fela-support="true"' : ''; | ||
var userAttributes = objectReduce(styleNodeAttributes, function (attributes, value, attribute) { | ||
return attributes + ' ' + attribute + '="' + value + '"'; | ||
}, ''); | ||
return '<style type="text/css" data-fela-rehydration="' + rehydrationIndex + '" data-fela-type="' + type + '"' + supportAttribute + mediaAttribute + '>' + css + '</style>'; | ||
return '<style type="text/css" data-fela-rehydration="' + rehydrationIndex + '" data-fela-type="' + type + '"' + supportAttribute + mediaAttribute + userAttributes + '>' + css + '</style>'; | ||
} |
@@ -17,3 +17,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
if (cacheCluster[key].length > 0) { | ||
markup += createStyleTagMarkup(cacheCluster[key], type, '', rehydrationIndex); | ||
markup += createStyleTagMarkup(cacheCluster[key], type, '', rehydrationIndex, false, renderer.styleNodeAttributes); | ||
} | ||
@@ -27,3 +27,3 @@ | ||
if (support) { | ||
styleMarkup += createStyleTagMarkup(support, RULE_TYPE, '', rehydrationIndex, true); | ||
styleMarkup += createStyleTagMarkup(support, RULE_TYPE, '', rehydrationIndex, true, renderer.styleNodeAttributes); | ||
} | ||
@@ -36,3 +36,3 @@ | ||
if (cacheCluster.mediaRules[media] && cacheCluster.mediaRules[media].length > 0) { | ||
markup += createStyleTagMarkup(cacheCluster.mediaRules[media], RULE_TYPE, media, rehydrationIndex); | ||
markup += createStyleTagMarkup(cacheCluster.mediaRules[media], RULE_TYPE, media, rehydrationIndex, false, renderer.styleNodeAttributes); | ||
} | ||
@@ -45,3 +45,3 @@ | ||
if (mediaSupport.length > 0) { | ||
markup += createStyleTagMarkup(mediaSupport, RULE_TYPE, media, rehydrationIndex, true); | ||
markup += createStyleTagMarkup(mediaSupport, RULE_TYPE, media, rehydrationIndex, true, renderer.styleNodeAttributes); | ||
} | ||
@@ -48,0 +48,0 @@ } |
@@ -19,2 +19,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
rehydration: rehydrationIndex, | ||
attributes: renderer.styleNodeAttributes, | ||
type: type | ||
@@ -34,2 +35,3 @@ }); | ||
rehydration: rehydrationIndex, | ||
attributes: renderer.styleNodeAttributes, | ||
support: true | ||
@@ -48,2 +50,3 @@ }); | ||
rehydration: rehydrationIndex, | ||
attributes: renderer.styleNodeAttributes, | ||
media: media | ||
@@ -62,2 +65,3 @@ }); | ||
rehydration: rehydrationIndex, | ||
attributes: renderer.styleNodeAttributes, | ||
support: true, | ||
@@ -64,0 +68,0 @@ media: media |
@@ -6,2 +6,5 @@ 'use strict'; | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
exports.default = createNode; | ||
@@ -24,2 +27,3 @@ | ||
var sortMediaQuery = arguments[2]; | ||
var styleNodeAttributes = arguments[3]; | ||
@@ -44,2 +48,14 @@ var head = targetDocument.head || {}; | ||
// applying custom style tag attributes | ||
for (var attribute in styleNodeAttributes) { | ||
node.setAttribute(attribute, styleNodeAttributes[attribute]); | ||
} | ||
// also apply attributes set globally with window.FelaConfig | ||
if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) !== undefined && window.FelaConfig) { | ||
for (var _attribute in window.FelaConfig.styleNodeAttributes) { | ||
node.setAttribute(_attribute, window.FelaConfig.styleNodeAttributes[_attribute]); | ||
} | ||
} | ||
var nodes = head.querySelectorAll('[data-fela-type]'); | ||
@@ -46,0 +62,0 @@ var sibling = (0, _getNodeSibling2.default)([].concat(_toConsumableArray(nodes)), attributes, sortMediaQuery); |
@@ -34,3 +34,3 @@ 'use strict'; | ||
if (!renderer.nodes[reference]) { | ||
var node = (0, _queryNode2.default)(attributes, targetDocument) || (0, _createNode2.default)(attributes, targetDocument, renderer.sortMediaQuery); | ||
var node = (0, _queryNode2.default)(attributes, targetDocument) || (0, _createNode2.default)(attributes, targetDocument, renderer.sortMediaQuery, renderer.styleNodeAttributes); | ||
@@ -37,0 +37,0 @@ renderer.nodes[reference] = node; |
@@ -7,2 +7,9 @@ 'use strict'; | ||
exports.default = createStyleTagMarkup; | ||
var _objectReduce = require('fast-loops/lib/objectReduce'); | ||
var _objectReduce2 = _interopRequireDefault(_objectReduce); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function createStyleTagMarkup(css, type) { | ||
@@ -12,7 +19,11 @@ var media = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
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="' + media + '"' : ''; | ||
var supportAttribute = support ? ' data-fela-support="true"' : ''; | ||
var userAttributes = (0, _objectReduce2.default)(styleNodeAttributes, function (attributes, value, attribute) { | ||
return attributes + ' ' + attribute + '="' + value + '"'; | ||
}, ''); | ||
return '<style type="text/css" data-fela-rehydration="' + rehydrationIndex + '" data-fela-type="' + type + '"' + supportAttribute + mediaAttribute + '>' + css + '</style>'; | ||
return '<style type="text/css" data-fela-rehydration="' + rehydrationIndex + '" data-fela-type="' + type + '"' + supportAttribute + mediaAttribute + userAttributes + '>' + css + '</style>'; | ||
} |
@@ -38,3 +38,3 @@ 'use strict'; | ||
if (cacheCluster[key].length > 0) { | ||
markup += (0, _createStyleTagMarkup2.default)(cacheCluster[key], type, '', rehydrationIndex); | ||
markup += (0, _createStyleTagMarkup2.default)(cacheCluster[key], type, '', rehydrationIndex, false, renderer.styleNodeAttributes); | ||
} | ||
@@ -48,3 +48,3 @@ | ||
if (support) { | ||
styleMarkup += (0, _createStyleTagMarkup2.default)(support, _felaUtils.RULE_TYPE, '', rehydrationIndex, true); | ||
styleMarkup += (0, _createStyleTagMarkup2.default)(support, _felaUtils.RULE_TYPE, '', rehydrationIndex, true, renderer.styleNodeAttributes); | ||
} | ||
@@ -57,3 +57,3 @@ | ||
if (cacheCluster.mediaRules[media] && cacheCluster.mediaRules[media].length > 0) { | ||
markup += (0, _createStyleTagMarkup2.default)(cacheCluster.mediaRules[media], _felaUtils.RULE_TYPE, media, rehydrationIndex); | ||
markup += (0, _createStyleTagMarkup2.default)(cacheCluster.mediaRules[media], _felaUtils.RULE_TYPE, media, rehydrationIndex, false, renderer.styleNodeAttributes); | ||
} | ||
@@ -66,3 +66,3 @@ | ||
if (mediaSupport.length > 0) { | ||
markup += (0, _createStyleTagMarkup2.default)(mediaSupport, _felaUtils.RULE_TYPE, media, rehydrationIndex, true); | ||
markup += (0, _createStyleTagMarkup2.default)(mediaSupport, _felaUtils.RULE_TYPE, media, rehydrationIndex, true, renderer.styleNodeAttributes); | ||
} | ||
@@ -69,0 +69,0 @@ } |
@@ -37,2 +37,3 @@ 'use strict'; | ||
rehydration: rehydrationIndex, | ||
attributes: renderer.styleNodeAttributes, | ||
type: type | ||
@@ -52,2 +53,3 @@ }); | ||
rehydration: rehydrationIndex, | ||
attributes: renderer.styleNodeAttributes, | ||
support: true | ||
@@ -66,2 +68,3 @@ }); | ||
rehydration: rehydrationIndex, | ||
attributes: renderer.styleNodeAttributes, | ||
media: media | ||
@@ -80,2 +83,3 @@ }); | ||
rehydration: rehydrationIndex, | ||
attributes: renderer.styleNodeAttributes, | ||
support: true, | ||
@@ -82,0 +86,0 @@ media: media |
{ | ||
"name": "fela-dom", | ||
"version": "11.1.2", | ||
"version": "11.2.0", | ||
"description": "Fela package for working with the DOM", | ||
@@ -29,11 +29,11 @@ "main": "lib/index.js", | ||
"fast-loops": "^1.0.1", | ||
"fela-utils": "^11.1.2", | ||
"fela-utils": "^11.2.0", | ||
"sort-css-media-queries": "^1.4.3" | ||
}, | ||
"devDependencies": { | ||
"fela": "^11.1.2", | ||
"fela-preset-web": "^11.1.2", | ||
"fela-tools": "^11.1.2" | ||
"fela": "^11.2.0", | ||
"fela-preset-web": "^11.2.0", | ||
"fela-tools": "^11.2.0" | ||
}, | ||
"gitHead": "a4f6498c8842873285a80ed1c9eb8dcde4b3370b" | ||
"gitHead": "180a1819c65d52f8f83d70fa717deeb6bb52389e" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61305
1319
Updatedfela-utils@^11.2.0