Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fela-dom

Package Overview
Dependencies
Maintainers
2
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fela-dom - npm Package Compare versions

Comparing version 10.2.2 to 10.2.3

4

es/dom/__helpers__/cleanHead.js
export default function cleanHead() {
var _document = document,
head = _document.head;
var head = document.head;
while (head.firstChild) {

@@ -6,0 +4,0 @@ head.removeChild(head.firstChild);

@@ -33,6 +33,3 @@ import { FONT_TYPE, STATIC_TYPE, KEYFRAME_TYPE, RULE_TYPE } from 'fela-utils';

return getRuleScore(support ? 4 : 3, media, mediaQueryOrder);
default:
// TODO: warning
return 9999;
}
}

@@ -7,3 +7,2 @@ import objectReduce from 'fast-loops/lib/objectReduce';

support = _ref.support;
var id = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';

@@ -13,3 +12,2 @@ var head = document.head || {};

var node = document.createElement('style');
node.setAttribute('data-fela-id', id);
node.setAttribute('data-fela-type', type);

@@ -28,4 +26,4 @@ node.type = 'text/css';

// to correctly inject the node just before it
var moreSpecificReference = objectReduce(nodes, function (closest, currentNode, reference) {
return currentNode.score > score && (!closest || nodes[closest].score > currentNode.score) ? reference : closest;
var moreSpecificReference = objectReduce(nodes, function (closest, node, reference) {
return node.score > score && (!closest || nodes[closest].score > node.score) ? reference : closest;
}, undefined);

@@ -32,0 +30,0 @@

/* eslint-disable consistent-return */
import objectEach from 'fast-loops/lib/objectEach';
import { RULE_TYPE, KEYFRAME_TYPE, FONT_TYPE, STATIC_TYPE, CLEAR_TYPE, generateCSSRule } from 'fela-utils';
import { RULE_TYPE, KEYFRAME_TYPE, FONT_TYPE, STATIC_TYPE, CLEAR_TYPE, getRuleScore, generateCSSRule } from 'fela-utils';

@@ -18,3 +18,2 @@ import getNodeFromCache from './getNodeFromCache';

renderer.nodes = {};
renderer.scoreIndex = {};
return;

@@ -38,7 +37,4 @@ }

break;
default:
// TODO: warning
break;
}
};
}

@@ -20,3 +20,3 @@ import calculateNodeScore from './calculateNodeScore';

var score = calculateNodeScore(attributes, renderer.mediaQueryOrder);
var node = queryNode(attributes, renderer.rendererId) || createNode(renderer.nodes, score, attributes, renderer.rendererId);
var node = queryNode(attributes) || createNode(renderer.nodes, score, attributes);

@@ -23,0 +23,0 @@ renderer.nodes[reference] = {

@@ -9,11 +9,8 @@ import { generateCSSRule, generateCSSSupportRule, getRuleScore } from 'fela-utils';

support = _ref.support,
media = _ref.media,
pseudo = _ref.pseudo;
var nodeReference = media + support;
// only use insertRule in production as browser devtools might have
// weird behavior if used together with insertRule at runtime
if (renderer.devMode) {
insertRuleInDevMode(renderer, node);
return;
return insertRuleInDevMode(renderer, node);
}

@@ -25,22 +22,12 @@

var index = cssRules.length;
if (score === 0) {
if (renderer.scoreIndex[nodeReference] === undefined) {
index = 0;
} else {
index = renderer.scoreIndex[nodeReference] + 1;
// TODO: (PERF) instead of checking the score every time
// we could save the latest score=0 index to quickly inject
// basic styles and only check for score!=0 (e.g. pseudo classes)
for (var i = 0, len = cssRules.length; i < len; ++i) {
if (cssRules[i].score > score) {
index = i;
break;
}
} else {
// we start iterating from the last score=0 entry
// to corretly inject pseudo classes etc.
var startIndex = renderer.scoreIndex[nodeReference] || 0;
for (var i = startIndex, len = cssRules.length; i < len; ++i) {
if (cssRules[i].score > score) {
index = i;
break;
}
}
}

@@ -57,16 +44,6 @@

if (score === 0) {
renderer.scoreIndex[nodeReference] = index;
}
cssRules[index].score = score;
} catch (e) {
// We're disabled these warnings due to false-positive errors with browser prefixes
// See https://github.com/rofrischmann/fela/issues/634
// console.warn(
// `An error occurred while inserting the rules into DOM.\n`,
// declaration.replace(/;/g, ';\n'),
// e
// )
console.warn('An error occurred while inserting the rules into DOM.\n', declaration.replace(/;/g, ';\n'), e);
}
}

@@ -13,9 +13,9 @@ import { RULE_TYPE } from 'fela-utils';

var currentSheet = sheetList.find(function (sheet) {
var sheet = sheetList.find(function (sheet) {
return sheet.type === RULE_TYPE && sheet.media === media && sheet.support === support;
});
if (currentSheet) {
node.textContent = currentSheet.css;
if (sheet) {
node.textContent = sheet.css;
}
}

@@ -7,9 +7,7 @@

support = _ref.support;
var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var idQuery = '[data-fela-id="' + id + '"]';
var mediaQuery = media ? '[media="' + media + '"]' : ':not([media])';
var supportQuery = support ? '[data-fela-support="true"]' : ':not([data-fela-support="true"])';
var mediaQuery = media ? '[media="' + media + '"]' : '';
var supportQuery = support ? '[data-fela-support="true"]' : '';
return document.querySelector('[data-fela-type="' + type + '"]' + idQuery + supportQuery + mediaQuery);
return document.querySelector('[data-fela-type="' + type + '"]' + supportQuery + mediaQuery);
}

@@ -17,5 +17,3 @@ import arrayEach from 'fast-loops/lib/arrayEach';

var idQuery = '[data-fela-id="' + renderer.rendererId + '"]';
arrayEach(document.querySelectorAll('[data-fela-type]' + idQuery), function (node) {
arrayEach(document.querySelectorAll('[data-fela-type]'), function (node) {
var rehydrationAttribute = node.getAttribute('data-fela-rehydration') || -1;

@@ -51,14 +49,6 @@ var rehydrationIndex = renderer.uniqueRuleIdentifier || parseInt(rehydrationAttribute, 10);

if (node.sheet && node.sheet.cssRules) {
var nodeReference = media + support;
arrayEach(node.sheet.cssRules, function (rule, index) {
arrayEach(node.sheet.cssRules, function (rule) {
var selectorText = rule.conditionText ? rule.cssRules[0].selectorText : rule.selectorText;
var score = getRuleScore(renderer.ruleOrder, selectorText.split(CLASSNAME_REGEX)[1]);
if (score === 0) {
renderer.scoreIndex[nodeReference] = index;
}
rule.score = score;
rule.score = getRuleScore(renderer.ruleOrder, selectorText.split(CLASSNAME_REGEX)[1]);
});

@@ -65,0 +55,0 @@ }

@@ -14,3 +14,2 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

// eslint-disable-next-line no-cond-assign
while (decl = SUPPORT_REGEX.exec(css)) {

@@ -17,0 +16,0 @@ var _decl = decl,

@@ -7,3 +7,2 @@ import objectEach from 'fast-loops/lib/objectEach';

if (!renderer.updateSubscription) {
renderer.scoreIndex = {};
renderer.nodes = {};

@@ -10,0 +9,0 @@

export default function createStyleTagMarkup(css, type) {
var rendererId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var media = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
var rehydrationIndex = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1;
var support = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
export default function createStyleMarkup(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 idAttribute = ' data-fela-id="' + rendererId + '"';
var mediaAttribute = media.length > 0 ? ' media="' + media + '"' : '';
var supportAttribute = support ? ' data-fela-support="true"' : '';
return '<style type="text/css" data-fela-rehydration="' + rehydrationIndex + '" data-fela-type="' + type + '"' + idAttribute + supportAttribute + mediaAttribute + '>' + css + '</style>';
return '<style type="text/css" data-fela-rehydration="' + rehydrationIndex + '" data-fela-type="' + type + '"' + supportAttribute + mediaAttribute + '>' + 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, renderer.rendererId, '', rehydrationIndex);
markup += createStyleTagMarkup(cacheCluster[key], type, '', rehydrationIndex);
}

@@ -27,3 +27,3 @@

if (support) {
styleMarkup += createStyleTagMarkup(support, RULE_TYPE, renderer.rendererId, '', rehydrationIndex, true);
styleMarkup += createStyleTagMarkup(support, RULE_TYPE, '', rehydrationIndex, true);
}

@@ -36,3 +36,3 @@

if (cacheCluster.mediaRules[media] && cacheCluster.mediaRules[media].length > 0) {
markup += createStyleTagMarkup(cacheCluster.mediaRules[media], RULE_TYPE, renderer.rendererId, media, rehydrationIndex);
markup += createStyleTagMarkup(cacheCluster.mediaRules[media], RULE_TYPE, media, rehydrationIndex);
}

@@ -45,3 +45,3 @@

if (mediaSupport.length > 0) {
markup += createStyleTagMarkup(mediaSupport, RULE_TYPE, renderer.rendererId, media, rehydrationIndex, true);
markup += createStyleTagMarkup(mediaSupport, RULE_TYPE, media, rehydrationIndex, true);
}

@@ -48,0 +48,0 @@ }

@@ -8,5 +8,3 @@ "use strict";

function cleanHead() {
var _document = document,
head = _document.head;
var head = document.head;
while (head.firstChild) {

@@ -13,0 +11,0 @@ head.removeChild(head.firstChild);

@@ -39,6 +39,3 @@ 'use strict';

return getRuleScore(support ? 4 : 3, media, mediaQueryOrder);
default:
// TODO: warning
return 9999;
}
}

@@ -18,3 +18,2 @@ 'use strict';

support = _ref.support;
var id = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';

@@ -24,3 +23,2 @@ var head = document.head || {};

var node = document.createElement('style');
node.setAttribute('data-fela-id', id);
node.setAttribute('data-fela-type', type);

@@ -39,4 +37,4 @@ node.type = 'text/css';

// to correctly inject the node just before it
var moreSpecificReference = (0, _objectReduce2.default)(nodes, function (closest, currentNode, reference) {
return currentNode.score > score && (!closest || nodes[closest].score > currentNode.score) ? reference : closest;
var moreSpecificReference = (0, _objectReduce2.default)(nodes, function (closest, node, reference) {
return node.score > score && (!closest || nodes[closest].score > node.score) ? reference : closest;
}, undefined);

@@ -43,0 +41,0 @@

@@ -34,3 +34,2 @@ 'use strict';

renderer.nodes = {};
renderer.scoreIndex = {};
return;

@@ -54,7 +53,4 @@ }

break;
default:
// TODO: warning
break;
}
};
}

@@ -36,3 +36,3 @@ 'use strict';

var score = (0, _calculateNodeScore2.default)(attributes, renderer.mediaQueryOrder);
var node = (0, _queryNode2.default)(attributes, renderer.rendererId) || (0, _createNode2.default)(renderer.nodes, score, attributes, renderer.rendererId);
var node = (0, _queryNode2.default)(attributes) || (0, _createNode2.default)(renderer.nodes, score, attributes);

@@ -39,0 +39,0 @@ renderer.nodes[reference] = {

@@ -20,11 +20,8 @@ 'use strict';

support = _ref.support,
media = _ref.media,
pseudo = _ref.pseudo;
var nodeReference = media + support;
// only use insertRule in production as browser devtools might have
// weird behavior if used together with insertRule at runtime
if (renderer.devMode) {
(0, _insertRuleInDevMode2.default)(renderer, node);
return;
return (0, _insertRuleInDevMode2.default)(renderer, node);
}

@@ -36,22 +33,12 @@

var index = cssRules.length;
if (score === 0) {
if (renderer.scoreIndex[nodeReference] === undefined) {
index = 0;
} else {
index = renderer.scoreIndex[nodeReference] + 1;
// TODO: (PERF) instead of checking the score every time
// we could save the latest score=0 index to quickly inject
// basic styles and only check for score!=0 (e.g. pseudo classes)
for (var i = 0, len = cssRules.length; i < len; ++i) {
if (cssRules[i].score > score) {
index = i;
break;
}
} else {
// we start iterating from the last score=0 entry
// to corretly inject pseudo classes etc.
var startIndex = renderer.scoreIndex[nodeReference] || 0;
for (var i = startIndex, len = cssRules.length; i < len; ++i) {
if (cssRules[i].score > score) {
index = i;
break;
}
}
}

@@ -68,16 +55,6 @@

if (score === 0) {
renderer.scoreIndex[nodeReference] = index;
}
cssRules[index].score = score;
} catch (e) {
// We're disabled these warnings due to false-positive errors with browser prefixes
// See https://github.com/rofrischmann/fela/issues/634
// console.warn(
// `An error occurred while inserting the rules into DOM.\n`,
// declaration.replace(/;/g, ';\n'),
// e
// )
console.warn('An error occurred while inserting the rules into DOM.\n', declaration.replace(/;/g, ';\n'), e);
}
}

@@ -24,9 +24,9 @@ 'use strict';

var currentSheet = sheetList.find(function (sheet) {
var sheet = sheetList.find(function (sheet) {
return sheet.type === _felaUtils.RULE_TYPE && sheet.media === media && sheet.support === support;
});
if (currentSheet) {
node.textContent = currentSheet.css;
if (sheet) {
node.textContent = sheet.css;
}
}

@@ -11,9 +11,7 @@ 'use strict';

support = _ref.support;
var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var idQuery = '[data-fela-id="' + id + '"]';
var mediaQuery = media ? '[media="' + media + '"]' : ':not([media])';
var supportQuery = support ? '[data-fela-support="true"]' : ':not([data-fela-support="true"])';
var mediaQuery = media ? '[media="' + media + '"]' : '';
var supportQuery = support ? '[data-fela-support="true"]' : '';
return document.querySelector('[data-fela-type="' + type + '"]' + idQuery + supportQuery + mediaQuery);
return document.querySelector('[data-fela-type="' + type + '"]' + supportQuery + mediaQuery);
}

@@ -39,5 +39,3 @@ 'use strict';

var idQuery = '[data-fela-id="' + renderer.rendererId + '"]';
(0, _arrayEach2.default)(document.querySelectorAll('[data-fela-type]' + idQuery), function (node) {
(0, _arrayEach2.default)(document.querySelectorAll('[data-fela-type]'), function (node) {
var rehydrationAttribute = node.getAttribute('data-fela-rehydration') || -1;

@@ -73,14 +71,6 @@ var rehydrationIndex = renderer.uniqueRuleIdentifier || parseInt(rehydrationAttribute, 10);

if (node.sheet && node.sheet.cssRules) {
var nodeReference = media + support;
(0, _arrayEach2.default)(node.sheet.cssRules, function (rule, index) {
(0, _arrayEach2.default)(node.sheet.cssRules, function (rule) {
var selectorText = rule.conditionText ? rule.cssRules[0].selectorText : rule.selectorText;
var score = (0, _felaUtils.getRuleScore)(renderer.ruleOrder, selectorText.split(CLASSNAME_REGEX)[1]);
if (score === 0) {
renderer.scoreIndex[nodeReference] = index;
}
rule.score = score;
rule.score = (0, _felaUtils.getRuleScore)(renderer.ruleOrder, selectorText.split(CLASSNAME_REGEX)[1]);
});

@@ -87,0 +77,0 @@ }

@@ -29,3 +29,2 @@ 'use strict';

// eslint-disable-next-line no-cond-assign
while (decl = SUPPORT_REGEX.exec(css)) {

@@ -32,0 +31,0 @@ var _decl = decl,

@@ -20,3 +20,2 @@ 'use strict';

if (!renderer.updateSubscription) {
renderer.scoreIndex = {};
renderer.nodes = {};

@@ -23,0 +22,0 @@

@@ -6,14 +6,12 @@ 'use strict';

});
exports.default = createStyleTagMarkup;
function createStyleTagMarkup(css, type) {
var rendererId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var media = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
var rehydrationIndex = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1;
var support = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
exports.default = createStyleMarkup;
function createStyleMarkup(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 idAttribute = ' data-fela-id="' + rendererId + '"';
var mediaAttribute = media.length > 0 ? ' media="' + media + '"' : '';
var supportAttribute = support ? ' data-fela-support="true"' : '';
return '<style type="text/css" data-fela-rehydration="' + rehydrationIndex + '" data-fela-type="' + type + '"' + idAttribute + supportAttribute + mediaAttribute + '>' + css + '</style>';
return '<style type="text/css" data-fela-rehydration="' + rehydrationIndex + '" data-fela-type="' + type + '"' + supportAttribute + mediaAttribute + '>' + css + '</style>';
}

@@ -38,3 +38,3 @@ 'use strict';

if (cacheCluster[key].length > 0) {
markup += (0, _createStyleTagMarkup2.default)(cacheCluster[key], type, renderer.rendererId, '', rehydrationIndex);
markup += (0, _createStyleTagMarkup2.default)(cacheCluster[key], type, '', rehydrationIndex);
}

@@ -48,3 +48,3 @@

if (support) {
styleMarkup += (0, _createStyleTagMarkup2.default)(support, _felaUtils.RULE_TYPE, renderer.rendererId, '', rehydrationIndex, true);
styleMarkup += (0, _createStyleTagMarkup2.default)(support, _felaUtils.RULE_TYPE, '', rehydrationIndex, true);
}

@@ -57,3 +57,3 @@

if (cacheCluster.mediaRules[media] && cacheCluster.mediaRules[media].length > 0) {
markup += (0, _createStyleTagMarkup2.default)(cacheCluster.mediaRules[media], _felaUtils.RULE_TYPE, renderer.rendererId, media, rehydrationIndex);
markup += (0, _createStyleTagMarkup2.default)(cacheCluster.mediaRules[media], _felaUtils.RULE_TYPE, media, rehydrationIndex);
}

@@ -66,3 +66,3 @@

if (mediaSupport.length > 0) {
markup += (0, _createStyleTagMarkup2.default)(mediaSupport, _felaUtils.RULE_TYPE, renderer.rendererId, media, rehydrationIndex, true);
markup += (0, _createStyleTagMarkup2.default)(mediaSupport, _felaUtils.RULE_TYPE, media, rehydrationIndex, true);
}

@@ -69,0 +69,0 @@ }

{
"name": "fela-dom",
"version": "10.2.2",
"version": "10.2.3",
"description": "Fela package for working with the DOM",

@@ -29,10 +29,10 @@ "main": "lib/index.js",

"fast-loops": "^1.0.1",
"fela-utils": "^10.2.2"
"fela-utils": "^10.2.3"
},
"devDependencies": {
"fela": "^10.2.2",
"fela-preset-web": "^10.2.2",
"fela-tools": "^10.2.2"
"fela": "^10.2.3",
"fela-preset-web": "^10.2.3",
"fela-tools": "^10.2.3"
},
"gitHead": "b3f7f53c5697e2c318d0490527e21852984242b9"
"gitHead": "4edeeffc5be2e05473a52c24523dbebcd9e0ef0d"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc