grep-components 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -51
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2065,6 +2065,11 @@ var weakMemoize = function weakMemoize(func) {
|
|
|
2065
2065
|
};
|
|
2066
2066
|
};
|
|
2067
2067
|
|
|
2068
|
+
var last = function last(arr) {
|
|
2069
|
+
return arr.length ? arr[arr.length - 1] : null;
|
|
2070
|
+
}; // based on https://github.com/thysultan/stylis.js/blob/e6843c373ebcbbfade25ebcc23f540ed8508da0a/src/Tokenizer.js#L239-L244
|
|
2071
|
+
|
|
2072
|
+
|
|
2068
2073
|
var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
|
|
2069
2074
|
var previous = 0;
|
|
2070
2075
|
var character = 0;
|
|
@@ -2192,64 +2197,19 @@ var removeLabel = function removeLabel(element) {
|
|
|
2192
2197
|
var ignoreFlag = 'emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason';
|
|
2193
2198
|
|
|
2194
2199
|
var isIgnoringComment = function isIgnoringComment(element) {
|
|
2195
|
-
return element.type === 'comm' && element.children.indexOf(ignoreFlag) > -1;
|
|
2200
|
+
return !!element && element.type === 'comm' && element.children.indexOf(ignoreFlag) > -1;
|
|
2196
2201
|
};
|
|
2197
2202
|
|
|
2198
2203
|
var createUnsafeSelectorsAlarm = function createUnsafeSelectorsAlarm(cache) {
|
|
2199
2204
|
return function (element, index, children) {
|
|
2200
|
-
if (element.type !== 'rule'
|
|
2205
|
+
if (element.type !== 'rule') return;
|
|
2201
2206
|
var unsafePseudoClasses = element.value.match(/(:first|:nth|:nth-last)-child/g);
|
|
2202
2207
|
|
|
2203
|
-
if (unsafePseudoClasses) {
|
|
2204
|
-
var
|
|
2205
|
-
//
|
|
2206
|
-
// considering this input:
|
|
2207
|
-
// .a {
|
|
2208
|
-
// .b /* comm */ {}
|
|
2209
|
-
// color: hotpink;
|
|
2210
|
-
// }
|
|
2211
|
-
// we get output corresponding to this:
|
|
2212
|
-
// .a {
|
|
2213
|
-
// & {
|
|
2214
|
-
// /* comm */
|
|
2215
|
-
// color: hotpink;
|
|
2216
|
-
// }
|
|
2217
|
-
// .b {}
|
|
2218
|
-
// }
|
|
2219
|
-
|
|
2220
|
-
var commentContainer = isNested ? children[0].children : // global rule at the root level
|
|
2221
|
-
children;
|
|
2222
|
-
|
|
2223
|
-
for (var i = commentContainer.length - 1; i >= 0; i--) {
|
|
2224
|
-
var node = commentContainer[i];
|
|
2225
|
-
|
|
2226
|
-
if (node.line < element.line) {
|
|
2227
|
-
break;
|
|
2228
|
-
} // it is quite weird but comments are *usually* put at `column: element.column - 1`
|
|
2229
|
-
// so we seek *from the end* for the node that is earlier than the rule's `element` and check that
|
|
2230
|
-
// this will also match inputs like this:
|
|
2231
|
-
// .a {
|
|
2232
|
-
// /* comm */
|
|
2233
|
-
// .b {}
|
|
2234
|
-
// }
|
|
2235
|
-
//
|
|
2236
|
-
// but that is fine
|
|
2237
|
-
//
|
|
2238
|
-
// it would be the easiest to change the placement of the comment to be the first child of the rule:
|
|
2239
|
-
// .a {
|
|
2240
|
-
// .b { /* comm */ }
|
|
2241
|
-
// }
|
|
2242
|
-
// with such inputs we wouldn't have to search for the comment at all
|
|
2243
|
-
// TODO: consider changing this comment placement in the next major version
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
if (node.column < element.column) {
|
|
2247
|
-
if (isIgnoringComment(node)) {
|
|
2248
|
-
return;
|
|
2249
|
-
}
|
|
2208
|
+
if (unsafePseudoClasses && cache.compat !== true) {
|
|
2209
|
+
var prevElement = index > 0 ? children[index - 1] : null;
|
|
2250
2210
|
|
|
2251
|
-
|
|
2252
|
-
|
|
2211
|
+
if (prevElement && isIgnoringComment(last(prevElement.children))) {
|
|
2212
|
+
return;
|
|
2253
2213
|
}
|
|
2254
2214
|
|
|
2255
2215
|
unsafePseudoClasses.forEach(function (unsafePseudoClass) {
|
|
@@ -2499,12 +2459,14 @@ function _extends() {
|
|
|
2499
2459
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
2500
2460
|
for (var i = 1; i < arguments.length; i++) {
|
|
2501
2461
|
var source = arguments[i];
|
|
2462
|
+
|
|
2502
2463
|
for (var key in source) {
|
|
2503
2464
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2504
2465
|
target[key] = source[key];
|
|
2505
2466
|
}
|
|
2506
2467
|
}
|
|
2507
2468
|
}
|
|
2469
|
+
|
|
2508
2470
|
return target;
|
|
2509
2471
|
};
|
|
2510
2472
|
return _extends.apply(this, arguments);
|