@tsrx/vue 0.1.8 → 0.1.10
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/package.json +2 -2
- package/src/transform.js +11 -65
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Vue compiler built on @tsrx/core",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.10",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"esrap": "^2.2.8",
|
|
32
32
|
"is-reference": "^3.0.3",
|
|
33
33
|
"zimmerframe": "^1.1.2",
|
|
34
|
-
"@tsrx/core": "0.1.
|
|
34
|
+
"@tsrx/core": "0.1.10"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"vue": ">=3.5",
|
package/src/transform.js
CHANGED
|
@@ -12,8 +12,10 @@ import {
|
|
|
12
12
|
componentToFunctionDeclaration,
|
|
13
13
|
createJsxTransform,
|
|
14
14
|
error,
|
|
15
|
+
is_component_like_element,
|
|
15
16
|
MERGE_REFS_INTERNAL_NAME,
|
|
16
17
|
NORMALIZE_SPREAD_PROPS_INTERNAL_NAME,
|
|
18
|
+
rewriteHostHtmlChildren as rewrite_host_html_children,
|
|
17
19
|
setLocation,
|
|
18
20
|
toJsxAttribute,
|
|
19
21
|
} from '@tsrx/core';
|
|
@@ -962,34 +964,16 @@ function rewrite_host_text_or_html_children(
|
|
|
962
964
|
) {
|
|
963
965
|
const source_children = raw_children || walked_children;
|
|
964
966
|
const is_composite = is_component_like_element(node);
|
|
965
|
-
const html_children = source_children.filter((child) => child?.type === 'Html');
|
|
966
967
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
transform_context?.filename ?? null,
|
|
977
|
-
html_children[0],
|
|
978
|
-
transform_context?.errors,
|
|
979
|
-
transform_context?.comments,
|
|
980
|
-
);
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
const walked_html = walked_children[0] || html_children[0];
|
|
984
|
-
attributes.push(
|
|
985
|
-
create_jsx_attribute(
|
|
986
|
-
'innerHTML',
|
|
987
|
-
to_jsx_expression_container(walked_html.expression, html_children[0]),
|
|
988
|
-
html_children[0],
|
|
989
|
-
),
|
|
990
|
-
);
|
|
991
|
-
|
|
992
|
-
return { children: [], selfClosing: true };
|
|
968
|
+
const html_child_transform = rewrite_host_html_children(
|
|
969
|
+
node,
|
|
970
|
+
walked_children,
|
|
971
|
+
raw_children,
|
|
972
|
+
attributes,
|
|
973
|
+
transform_context,
|
|
974
|
+
);
|
|
975
|
+
if (html_child_transform) {
|
|
976
|
+
return html_child_transform;
|
|
993
977
|
}
|
|
994
978
|
|
|
995
979
|
if (!is_composite && source_children.length === 1 && source_children[0]?.type === 'Text') {
|
|
@@ -999,44 +983,6 @@ function rewrite_host_text_or_html_children(
|
|
|
999
983
|
return null;
|
|
1000
984
|
}
|
|
1001
985
|
|
|
1002
|
-
/**
|
|
1003
|
-
* @param {any} node
|
|
1004
|
-
* @returns {boolean}
|
|
1005
|
-
*/
|
|
1006
|
-
function is_component_like_element(node) {
|
|
1007
|
-
const id = node?.id;
|
|
1008
|
-
if (!id) return false;
|
|
1009
|
-
if (id.type === 'Identifier') return /^[A-Z]/.test(id.name);
|
|
1010
|
-
if (id.type === 'MemberExpression') return true;
|
|
1011
|
-
return false;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
* @param {any[]} attributes
|
|
1016
|
-
* @param {string} name
|
|
1017
|
-
* @returns {boolean}
|
|
1018
|
-
*/
|
|
1019
|
-
function has_dom_content_attribute(attributes, name) {
|
|
1020
|
-
return attributes.some(
|
|
1021
|
-
(/** @type {any} */ attribute) =>
|
|
1022
|
-
attribute &&
|
|
1023
|
-
(attribute.type === 'JSXSpreadAttribute' ||
|
|
1024
|
-
(attribute.type === 'JSXAttribute' &&
|
|
1025
|
-
attribute.name?.type === 'JSXIdentifier' &&
|
|
1026
|
-
attribute.name.name === name)),
|
|
1027
|
-
);
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
/**
|
|
1031
|
-
* @param {string} name
|
|
1032
|
-
* @param {any} value
|
|
1033
|
-
* @param {any} source_node
|
|
1034
|
-
* @returns {any}
|
|
1035
|
-
*/
|
|
1036
|
-
function create_jsx_attribute(name, value, source_node) {
|
|
1037
|
-
return builders.jsx_attribute(builders.jsx_id(name), value, false, source_node);
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
986
|
/**
|
|
1041
987
|
* @param {any} expression
|
|
1042
988
|
* @param {any} source_node
|