Compare commits
2 Commits
780937a368
...
143862059a
| Author | SHA1 | Date | |
|---|---|---|---|
| 143862059a | |||
| 07237e833b |
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@because/hype",
|
"name": "@because/hype",
|
||||||
"version": "0.0.10",
|
"version": "0.0.11",
|
||||||
"module": "src/index.tsx",
|
"module": "src/index.tsx",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,25 @@ const minify = function(el) {
|
||||||
|
|
||||||
const convert = {
|
const convert = {
|
||||||
comment: [],
|
comment: [],
|
||||||
line: []
|
line: [],
|
||||||
|
script: []
|
||||||
|
};
|
||||||
|
|
||||||
|
const preserveScripts = function (el) {
|
||||||
|
convert.script = [];
|
||||||
|
el = el.replace(/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi, function (match, open, content, close) {
|
||||||
|
if (!content.trim()) return match;
|
||||||
|
convert.script.push(content);
|
||||||
|
return open + '[#s# : ' + (convert.script.length - 1) + ' : #s#]' + close;
|
||||||
|
});
|
||||||
|
return el;
|
||||||
|
};
|
||||||
|
|
||||||
|
const restoreScripts = function (el) {
|
||||||
|
convert.script.forEach(function (content, index) {
|
||||||
|
el = el.replace('[#s# : ' + index + ' : #s#]', content);
|
||||||
|
});
|
||||||
|
return el;
|
||||||
};
|
};
|
||||||
|
|
||||||
const comment = function (el) {
|
const comment = function (el) {
|
||||||
|
|
@ -125,11 +143,13 @@ const tidy = function (el) {
|
||||||
|
|
||||||
const render = function (el, opt) {
|
const render = function (el, opt) {
|
||||||
el = closing(el);
|
el = closing(el);
|
||||||
|
el = preserveScripts(el);
|
||||||
el = comment(el);
|
el = comment(el);
|
||||||
el = entity(el);
|
el = entity(el);
|
||||||
el = minify(el);
|
el = minify(el);
|
||||||
el = line(el);
|
el = line(el);
|
||||||
el = tidy(el);
|
el = tidy(el);
|
||||||
|
el = restoreScripts(el);
|
||||||
|
|
||||||
return el;
|
return el;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user