@jsenv/ast 6.3.1 → 6.3.5
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 +4 -4
- package/src/html/html_node.js +32 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/ast",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.5",
|
|
4
4
|
"description": "Parse and transform HTML, CSS and JS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"/src/"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@babel/parser": "7.
|
|
32
|
+
"@babel/parser": "7.26.2",
|
|
33
33
|
"@jsenv/humanize": "1.2.8",
|
|
34
34
|
"@jsenv/urls": "2.5.2",
|
|
35
|
-
"acorn": "8.
|
|
35
|
+
"acorn": "8.14.0",
|
|
36
36
|
"acorn-import-attributes": "1.9.5",
|
|
37
37
|
"acorn-walk": "8.3.4",
|
|
38
|
-
"parse5": "7.1
|
|
38
|
+
"parse5": "7.2.1",
|
|
39
39
|
"postcss": "8.4.47",
|
|
40
40
|
"postcss-value-parser": "4.2.0"
|
|
41
41
|
}
|
package/src/html/html_node.js
CHANGED
|
@@ -130,9 +130,38 @@ const getJsenvScriptsNode = (htmlAst) => {
|
|
|
130
130
|
jsenvScripts = createHtmlNode({
|
|
131
131
|
tagName: "jsenv-scripts",
|
|
132
132
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
const headNode = findChild(htmlAst, (node) => node.nodeName === "html")
|
|
134
|
+
.childNodes[0];
|
|
135
|
+
let after = headNode.childNodes[0];
|
|
136
|
+
for (const child of headNode.childNodes) {
|
|
137
|
+
if (child.nodeName === "link") {
|
|
138
|
+
after = child;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (child.nodeName === "script") {
|
|
142
|
+
const { type } = analyzeScriptNode(child);
|
|
143
|
+
if (type === "js_classic") {
|
|
144
|
+
insertHtmlNodeBefore(jsenvScripts, child);
|
|
145
|
+
return jsenvScripts;
|
|
146
|
+
}
|
|
147
|
+
if (type === "importmap") {
|
|
148
|
+
insertHtmlNodeAfter(jsenvScripts, child);
|
|
149
|
+
return jsenvScripts;
|
|
150
|
+
}
|
|
151
|
+
if (type === "js_module") {
|
|
152
|
+
insertHtmlNodeBefore(jsenvScripts, child);
|
|
153
|
+
return jsenvScripts;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (child.nodeName === "meta") {
|
|
157
|
+
after = child;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (after) {
|
|
161
|
+
insertHtmlNodeAfter(jsenvScripts, after);
|
|
162
|
+
return jsenvScripts;
|
|
163
|
+
}
|
|
164
|
+
injectHtmlNode(htmlAst, jsenvScripts);
|
|
136
165
|
return jsenvScripts;
|
|
137
166
|
};
|
|
138
167
|
const stringifyParams = (params, prefix = "") => {
|