babel-plugin-jsx-dom-expressions 0.35.10 → 0.35.12
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/index.js +44 -14
- package/package.json +16 -12
package/index.js
CHANGED
|
@@ -5,10 +5,7 @@ var t = require('@babel/types');
|
|
|
5
5
|
var helperModuleImports = require('@babel/helper-module-imports');
|
|
6
6
|
var htmlEntities = require('html-entities');
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
function _interopNamespace(e) {
|
|
11
|
-
if (e && e.__esModule) return e;
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
12
9
|
var n = Object.create(null);
|
|
13
10
|
if (e) {
|
|
14
11
|
Object.keys(e).forEach(function (k) {
|
|
@@ -21,12 +18,11 @@ function _interopNamespace(e) {
|
|
|
21
18
|
}
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
|
-
n
|
|
21
|
+
n.default = e;
|
|
25
22
|
return Object.freeze(n);
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
var
|
|
29
|
-
var t__namespace = /*#__PURE__*/_interopNamespace(t);
|
|
25
|
+
var t__namespace = /*#__PURE__*/_interopNamespaceDefault(t);
|
|
30
26
|
|
|
31
27
|
const booleans = [
|
|
32
28
|
"allowfullscreen",
|
|
@@ -1844,6 +1840,7 @@ function setAttr$1(attribute, results, name, value, isSVG) {
|
|
|
1844
1840
|
let parts;
|
|
1845
1841
|
if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
|
|
1846
1842
|
name = parts[1];
|
|
1843
|
+
parts[0];
|
|
1847
1844
|
}
|
|
1848
1845
|
|
|
1849
1846
|
name = toAttribute(name, isSVG);
|
|
@@ -3222,27 +3219,60 @@ var config = {
|
|
|
3222
3219
|
contextToCustomElements: false,
|
|
3223
3220
|
staticMarker: "@once",
|
|
3224
3221
|
effectWrapper: "effect",
|
|
3225
|
-
memoWrapper: "memo"
|
|
3222
|
+
memoWrapper: "memo",
|
|
3223
|
+
validate: false
|
|
3224
|
+
};
|
|
3225
|
+
|
|
3226
|
+
const { isValidHTMLNesting } = require("validate-html-nesting");
|
|
3227
|
+
|
|
3228
|
+
// From https://github.com/MananTank/babel-plugin-validate-jsx-nesting/blob/main/src/index.js
|
|
3229
|
+
const JSXValidator = {
|
|
3230
|
+
JSXElement(path) {
|
|
3231
|
+
const elName = path.node.openingElement.name;
|
|
3232
|
+
if (!t__namespace.isJSXIdentifier(elName)) return;
|
|
3233
|
+
const elTagName = elName.name;
|
|
3234
|
+
if (!isComponent(elTagName)) return;
|
|
3235
|
+
const parent = path.parent;
|
|
3236
|
+
if (!t__namespace.isJSXElement(parent)) return;
|
|
3237
|
+
const parentElName = parent.openingElement.name;
|
|
3238
|
+
if (!t__namespace.isJSXIdentifier(parentElName)) return;
|
|
3239
|
+
const parentElTagName = parentElName.name;
|
|
3240
|
+
if (!isComponent(parentElTagName)) {
|
|
3241
|
+
if (!isValidHTMLNesting(parentElTagName, elTagName)) {
|
|
3242
|
+
throw path.buildCodeFrameError(
|
|
3243
|
+
`Invalid JSX: <${elTagName}> cannot be child of <${parentElTagName}>`
|
|
3244
|
+
);
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3226
3248
|
};
|
|
3227
3249
|
|
|
3228
|
-
var preprocess = (path, { opts })
|
|
3229
|
-
const merged = path.hub.file.metadata.config = Object.assign({}, config, opts);
|
|
3250
|
+
var preprocess = (path, { opts }) => {
|
|
3251
|
+
const merged = (path.hub.file.metadata.config = Object.assign({}, config, opts));
|
|
3230
3252
|
const lib = merged.requireImportSource;
|
|
3231
3253
|
if (lib) {
|
|
3232
3254
|
const comments = path.hub.file.ast.comments;
|
|
3233
|
-
|
|
3255
|
+
let process = false;
|
|
3256
|
+
for (let i = 0; i < comments.length; i++) {
|
|
3234
3257
|
const comment = comments[i];
|
|
3235
3258
|
const index = comment.value.indexOf("@jsxImportSource");
|
|
3236
|
-
if (index > -1 && comment.value.slice(index).includes(lib))
|
|
3259
|
+
if (index > -1 && comment.value.slice(index).includes(lib)) {
|
|
3260
|
+
process = true;
|
|
3261
|
+
break;
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
if (!process) {
|
|
3265
|
+
path.skip();
|
|
3266
|
+
return;
|
|
3237
3267
|
}
|
|
3238
|
-
path.skip();
|
|
3239
3268
|
}
|
|
3269
|
+
if (merged.validate) path.traverse(JSXValidator);
|
|
3240
3270
|
};
|
|
3241
3271
|
|
|
3242
3272
|
var index = () => {
|
|
3243
3273
|
return {
|
|
3244
3274
|
name: "JSX DOM Expressions",
|
|
3245
|
-
inherits:
|
|
3275
|
+
inherits: SyntaxJSX.default,
|
|
3246
3276
|
visitor: {
|
|
3247
3277
|
JSXElement: transformJSX,
|
|
3248
3278
|
JSXFragment: transformJSX,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-jsx-dom-expressions",
|
|
3
3
|
"description": "A JSX to DOM plugin that wraps expressions for fine grained change detection",
|
|
4
|
-
"version": "0.35.
|
|
4
|
+
"version": "0.35.12",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -12,20 +12,24 @@
|
|
|
12
12
|
"main": "index.js",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "rollup -c",
|
|
16
|
-
"test": "
|
|
17
|
-
"test:coverage": "
|
|
18
|
-
"prepublishOnly": "
|
|
19
|
-
"prepare": "
|
|
15
|
+
"build": "rollup -c --bundleConfigAsCjs",
|
|
16
|
+
"test": "pnpm run build && jest --no-cache",
|
|
17
|
+
"test:coverage": "pnpm run build && jest --coverage --no-cache",
|
|
18
|
+
"prepublishOnly": "pnpm run build",
|
|
19
|
+
"prepare": "pnpm run build"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/helper-module-imports": "7.
|
|
23
|
-
"@babel/plugin-syntax-jsx": "^7.
|
|
24
|
-
"@babel/types": "^7.
|
|
25
|
-
"html-entities": "2.3.
|
|
22
|
+
"@babel/helper-module-imports": "7.18.6",
|
|
23
|
+
"@babel/plugin-syntax-jsx": "^7.18.6",
|
|
24
|
+
"@babel/types": "^7.20.7",
|
|
25
|
+
"html-entities": "2.3.3",
|
|
26
|
+
"validate-html-nesting": "^1.0.2"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
|
-
"@babel/core": "^7.
|
|
29
|
+
"@babel/core": "^7.20.12"
|
|
29
30
|
},
|
|
30
|
-
"
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@babel/core": "^7.20.12"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "7c83569e6b30a64cc08e5c8cbdc4b44235551b4b"
|
|
31
35
|
}
|