uglify-js-minify-css-allfiles 2.8.2 → 2.8.3
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Babel plugin to transform Element.append() calls to be compatible with older browsers.
|
|
2
|
+
* Babel plugin to transform native DOM Element.append() calls to be compatible with older browsers.
|
|
3
|
+
* Skips jQuery/library .append() calls (e.g., $(...).append(), jQuery(...).append()).
|
|
4
|
+
*
|
|
3
5
|
* This plugin converts:
|
|
4
6
|
* - element.append("text") to element.appendChild(document.createTextNode("text"))
|
|
5
7
|
* - element.append(3) to element.appendChild(document.createTextNode(3))
|
|
@@ -39,6 +41,35 @@ export default function ({ types: t }) {
|
|
|
39
41
|
);
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Checks if the object of a .append() call is a jQuery/library wrapper.
|
|
46
|
+
* Skips patterns like: $(...).append(), jQuery(...).append(), $el.append(),
|
|
47
|
+
* $(...).find(...).append() (chained jQuery calls)
|
|
48
|
+
*/
|
|
49
|
+
function isJQueryCall(objectPath) {
|
|
50
|
+
const node = objectPath.node;
|
|
51
|
+
|
|
52
|
+
// $(...).append() or jQuery(...).append()
|
|
53
|
+
if (t.isCallExpression(node)) {
|
|
54
|
+
const callee = node.callee;
|
|
55
|
+
// $() or jQuery()
|
|
56
|
+
if (t.isIdentifier(callee, { name: '$' }) || t.isIdentifier(callee, { name: 'jQuery' })) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
// $(...).find(...).append() — chained jQuery method calls
|
|
60
|
+
if (t.isMemberExpression(callee) && t.isCallExpression(callee.object)) {
|
|
61
|
+
return isJQueryCall(objectPath.get('callee').get('object'));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// $el.append() — variables starting with $
|
|
66
|
+
if (t.isIdentifier(node) && node.name.startsWith('$')) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
42
73
|
return {
|
|
43
74
|
name: 'append-polyfill-transform',
|
|
44
75
|
visitor: {
|
|
@@ -49,6 +80,9 @@ export default function ({ types: t }) {
|
|
|
49
80
|
if (!callee.isMemberExpression()) return;
|
|
50
81
|
if (!callee.get('property').isIdentifier({ name: 'append' })) return;
|
|
51
82
|
|
|
83
|
+
// Skip jQuery .append() calls
|
|
84
|
+
if (isJQueryCall(callee.get('object'))) return;
|
|
85
|
+
|
|
52
86
|
const args = path.node.arguments;
|
|
53
87
|
const objectNode = callee.get('object').node;
|
|
54
88
|
|