Skip to content

Commit b90eeb6

Browse files
committed
Move prefix definitions
1 parent 7ac7e5f commit b90eeb6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/ast.js

-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { FileSystemCache } from "./fsCache.js"
3232
* @property {Array<"render" | "css:scoped">} [currentTransformTypes]
3333
*/
3434

35-
3635
class AstSerializer {
3736
constructor(options = {}) {
3837
let { filePath } = Object.assign({
@@ -109,11 +108,6 @@ class AstSerializer {
109108

110109
static EOL = "\n";
111110

112-
static prefixes = {
113-
props: "@",
114-
dynamic: ":",
115-
}
116-
117111
/* Custom HTML attributes */
118112
static attrs = {
119113
TYPE: "webc:type",

src/attributeSerializer.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { AstSerializer } from "./ast.js";
21
import { ModuleScript } from "./moduleScript.cjs";
32
import { escapeAttribute } from 'entities/lib/escape.js';
43

54
class AttributeSerializer {
5+
static prefixes = {
6+
props: "@",
7+
dynamic: ":",
8+
}
9+
610
// Merge multiple style/class attributes into a single one, operates on :dynamic and @prop but with transformed values
711
// Usage by: `getString` function when writing attributes to the HTML tag output
812
// Usage by: when generating data object for render functions
@@ -74,17 +78,17 @@ class AttributeSerializer {
7478
}
7579

7680
static peekAttribute(name) {
77-
if(name.startsWith(AstSerializer.prefixes.props)) {
81+
if(name.startsWith(AttributeSerializer.prefixes.props)) {
7882
return {
79-
name: name.slice(AstSerializer.prefixes.props.length),
83+
name: name.slice(AttributeSerializer.prefixes.props.length),
8084
privacy: "private", // property
8185
evaluation: false,
8286
};
8387
}
8488

85-
if(name.startsWith(AstSerializer.prefixes.dynamic)) {
89+
if(name.startsWith(AttributeSerializer.prefixes.dynamic)) {
8690
return {
87-
name: name.slice(AstSerializer.prefixes.dynamic.length),
91+
name: name.slice(AttributeSerializer.prefixes.dynamic.length),
8892
privacy: "public",
8993
evaluation: "script",
9094
};

0 commit comments

Comments
 (0)