-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.es5.js
47 lines (32 loc) · 1.45 KB
/
index.es5.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _postcss = require("postcss");
var postcss = _interopRequireWildcard(_postcss);
var _stringifier = require("postcss/lib/stringifier");
var _stringifier2 = _interopRequireDefault(_stringifier);
var _fs = require("fs");
var _fs2 = _interopRequireDefault(_fs);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
exports.default = stringify;
class DomModule extends _stringifier2.default {
root(node, options = {}) {
let template, webcomponentHeader, webcomponentFooter;
try {
template = _fs2.default.readFileSync(`${ __dirname }/template.html`, "utf8");
webcomponentHeader = template.match(/^(.|\n)+<style>/)[0];
webcomponentFooter = template.match(/<\/style>(.|\n)+$/)[0];
} catch (error) {
console.error(error);
}
this.builder(webcomponentHeader.replace(/{{id}}/, options.id));
super.root(node);
this.builder(webcomponentFooter);
}
}
function stringify(node, builder) {
const domModule = new DomModule(builder);
domModule.root(node, { id: "test1" });
}