@htmlplus/element 0.7.5 → 0.7.7
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.
|
@@ -168,7 +168,7 @@ export const customElement = (options) => {
|
|
|
168
168
|
const template = t.templateLiteral(quasis, expressions);
|
|
169
169
|
// TODO
|
|
170
170
|
// if (!expressions.length) return template;
|
|
171
|
-
const { local } = addDependency(path, CONSTANTS.UTILS_PATH, CONSTANTS.UTILS_HTML_LOCAL, CONSTANTS.UTILS_HTML_IMPORTED);
|
|
171
|
+
const { local } = addDependency(path, CONSTANTS.UTILS_PATH, CONSTANTS.UTILS_HTML_LOCAL, CONSTANTS.UTILS_HTML_IMPORTED, true);
|
|
172
172
|
return t.taggedTemplateExpression(t.identifier(local), template);
|
|
173
173
|
};
|
|
174
174
|
path.replaceWith(transform(render(path.node)));
|
|
@@ -195,7 +195,7 @@ export const document = (options) => {
|
|
|
195
195
|
};
|
|
196
196
|
});
|
|
197
197
|
})();
|
|
198
|
-
const tags = getTags(context.class);
|
|
198
|
+
const tags = getTags(context.class).filter((tag) => !['part', 'slot'].includes(tag.key));
|
|
199
199
|
const title = capitalCase(context.componentKey);
|
|
200
200
|
const component = {
|
|
201
201
|
events,
|
|
@@ -30,7 +30,7 @@ export const style = (options) => {
|
|
|
30
30
|
}
|
|
31
31
|
if (!context.stylePath)
|
|
32
32
|
return;
|
|
33
|
-
const { local } = addDependency(context.fileAST, context.stylePath, CONSTANTS.STYLE_IMPORTED);
|
|
33
|
+
const { local } = addDependency(context.fileAST, context.stylePath, CONSTANTS.STYLE_IMPORTED, undefined, true);
|
|
34
34
|
// TODO: remove 'local!'
|
|
35
35
|
const property = t.classProperty(t.identifier(CONSTANTS.STATIC_STYLES), t.identifier(local), undefined, null, undefined, true);
|
|
36
36
|
t.addComment(property, 'leading', CONSTANTS.COMMENT_AUTO_ADDED_PROPERTY, true);
|
|
@@ -3,7 +3,5 @@ interface AddDependencyReturns {
|
|
|
3
3
|
local?: string;
|
|
4
4
|
node: ImportDeclaration;
|
|
5
5
|
}
|
|
6
|
-
export declare function addDependency(path: File | any, source: string): AddDependencyReturns;
|
|
7
|
-
export declare function addDependency(path: File | any, source: string, local: string): AddDependencyReturns;
|
|
8
|
-
export declare function addDependency(path: File | any, source: string, local: string, imported: string): AddDependencyReturns;
|
|
6
|
+
export declare function addDependency(path: File | any, source: string, local?: string, imported?: string, comment?: boolean): AddDependencyReturns;
|
|
9
7
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import t from '@babel/types';
|
|
2
2
|
import * as CONSTANTS from '../../constants/index.js';
|
|
3
3
|
import { visitor } from './visitor.js';
|
|
4
|
-
export function addDependency(path, source, local, imported) {
|
|
4
|
+
export function addDependency(path, source, local, imported, comment) {
|
|
5
5
|
const isDefault = local && !imported;
|
|
6
6
|
const isImport = local && imported;
|
|
7
7
|
const isNormal = !local && !imported;
|
|
@@ -54,7 +54,9 @@ export function addDependency(path, source, local, imported) {
|
|
|
54
54
|
// TODO
|
|
55
55
|
(file.program || file).body.unshift(declaration);
|
|
56
56
|
// TODO
|
|
57
|
-
|
|
57
|
+
if (comment) {
|
|
58
|
+
t.addComment(declaration, 'leading', CONSTANTS.COMMENT_AUTO_ADDED_DEPENDENCY, true);
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
61
|
return {
|
|
60
62
|
local,
|
package/compiler/utils/tags.js
CHANGED
|
@@ -32,7 +32,7 @@ export const getTags = (node, filter) => {
|
|
|
32
32
|
export const hasTag = (node, name) => {
|
|
33
33
|
return getTags(node).some((tag) => tag.key === name);
|
|
34
34
|
};
|
|
35
|
-
export const parseTag = (tag, spliter = '-') => {
|
|
35
|
+
export const parseTag = (tag, spliter = ' - ') => {
|
|
36
36
|
var _a, _b;
|
|
37
37
|
const sections = ((_a = tag.value) === null || _a === void 0 ? void 0 : _a.split(spliter)) || [];
|
|
38
38
|
const name = (_b = sections[0]) === null || _b === void 0 ? void 0 : _b.trim();
|