babel-plugin-jsx-dom-expressions 0.35.10 → 0.35.13
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 +43 -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,59 @@ var config = {
|
|
|
3222
3219
|
contextToCustomElements: false,
|
|
3223
3220
|
staticMarker: "@once",
|
|
3224
3221
|
effectWrapper: "effect",
|
|
3225
|
-
memoWrapper: "memo"
|
|
3222
|
+
memoWrapper: "memo",
|
|
3223
|
+
validate: true
|
|
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
|
+
const parent = path.parent;
|
|
3233
|
+
if (!t__namespace.isJSXElement(parent) || !t__namespace.isJSXIdentifier(elName)) return;
|
|
3234
|
+
const elTagName = elName.name;
|
|
3235
|
+
if (isComponent(elTagName)) return;
|
|
3236
|
+
const parentElName = parent.openingElement.name;
|
|
3237
|
+
if (!t__namespace.isJSXIdentifier(parentElName)) return;
|
|
3238
|
+
const parentElTagName = parentElName.name;
|
|
3239
|
+
if (!isComponent(parentElTagName)) {
|
|
3240
|
+
if (!isValidHTMLNesting(parentElTagName, elTagName)) {
|
|
3241
|
+
throw path.buildCodeFrameError(
|
|
3242
|
+
`Invalid JSX: <${elTagName}> cannot be child of <${parentElTagName}>`
|
|
3243
|
+
);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3226
3247
|
};
|
|
3227
3248
|
|
|
3228
|
-
var preprocess = (path, { opts })
|
|
3229
|
-
const merged = path.hub.file.metadata.config = Object.assign({}, config, opts);
|
|
3249
|
+
var preprocess = (path, { opts }) => {
|
|
3250
|
+
const merged = (path.hub.file.metadata.config = Object.assign({}, config, opts));
|
|
3230
3251
|
const lib = merged.requireImportSource;
|
|
3231
3252
|
if (lib) {
|
|
3232
3253
|
const comments = path.hub.file.ast.comments;
|
|
3233
|
-
|
|
3254
|
+
let process = false;
|
|
3255
|
+
for (let i = 0; i < comments.length; i++) {
|
|
3234
3256
|
const comment = comments[i];
|
|
3235
3257
|
const index = comment.value.indexOf("@jsxImportSource");
|
|
3236
|
-
if (index > -1 && comment.value.slice(index).includes(lib))
|
|
3258
|
+
if (index > -1 && comment.value.slice(index).includes(lib)) {
|
|
3259
|
+
process = true;
|
|
3260
|
+
break;
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
if (!process) {
|
|
3264
|
+
path.skip();
|
|
3265
|
+
return;
|
|
3237
3266
|
}
|
|
3238
|
-
path.skip();
|
|
3239
3267
|
}
|
|
3268
|
+
if (merged.validate) path.traverse(JSXValidator);
|
|
3240
3269
|
};
|
|
3241
3270
|
|
|
3242
3271
|
var index = () => {
|
|
3243
3272
|
return {
|
|
3244
3273
|
name: "JSX DOM Expressions",
|
|
3245
|
-
inherits:
|
|
3274
|
+
inherits: SyntaxJSX.default,
|
|
3246
3275
|
visitor: {
|
|
3247
3276
|
JSXElement: transformJSX,
|
|
3248
3277
|
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.13",
|
|
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.1.0"
|
|
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": "a7a444cd18147a73ae1c514f8defcc0efadf18d2"
|
|
31
35
|
}
|