@esportsplus/template 0.22.1 → 0.22.3
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/build/constants.js +1 -1
- package/build/html/index.js +11 -6
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/html/index.ts +13 -7
package/build/constants.js
CHANGED
|
@@ -26,7 +26,7 @@ const NODE_WHITELIST = {
|
|
|
26
26
|
'track': NODE_VOID,
|
|
27
27
|
'wbr': NODE_VOID
|
|
28
28
|
};
|
|
29
|
-
const REGEX_EMPTY_TEXT_NODES = /(>|})\s+(<|{)/g;
|
|
29
|
+
const REGEX_EMPTY_TEXT_NODES = /(>|}|\s)\s+(<|{|\s)/g;
|
|
30
30
|
const REGEX_EVENTS = /(?:\s*on[\w-:]+\s*=(?:\s*["'][^"']*["'])*)/g;
|
|
31
31
|
const REGEX_SLOT_ATTRIBUTES = /<[\w-]+([^><]*{{\$}}[^><]*)>/g;
|
|
32
32
|
const REGEX_SLOT_NODES = /<([\w-]+|[\/!])(?:([^><]*{{\$}}[^><]*)|(?:[^><]*))?>|{{\$}}/g;
|
package/build/html/index.js
CHANGED
|
@@ -4,16 +4,21 @@ import parser from './parser.js';
|
|
|
4
4
|
const html = (literals, ...values) => {
|
|
5
5
|
let { fragment, slots } = parser.parse(literals), clone = cloneNode.call(fragment, true);
|
|
6
6
|
if (slots !== null) {
|
|
7
|
-
let
|
|
7
|
+
let e, p;
|
|
8
8
|
for (let i = slots.length - 1; i >= 0; i--) {
|
|
9
|
-
let { fn, path } = slots[i];
|
|
10
|
-
if (
|
|
11
|
-
|
|
9
|
+
let { fn, name, path } = slots[i];
|
|
10
|
+
if (p !== path) {
|
|
11
|
+
e = clone;
|
|
12
12
|
for (let i = 0, n = path.length; i < n; i++) {
|
|
13
|
-
|
|
13
|
+
e = path[i].call(e);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
if (name === null) {
|
|
17
|
+
fn(e, values[i]);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
fn(e, name, values[i]);
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
return clone;
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/html/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { RENDERABLE, RENDERABLE_HTML_REACTIVE_ARRAY } from '~/constants';
|
|
|
3
3
|
import { Attribute, Attributes, Renderable, RenderableReactive } from '~/types';
|
|
4
4
|
import { cloneNode } from '~/utilities/node';
|
|
5
5
|
import parser from './parser';
|
|
6
|
+
import attributes from '~/attributes';
|
|
7
|
+
import slot from '~/slot';
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
type Values<T> = Attribute | Attributes<any> | Renderable<T>;
|
|
@@ -13,21 +15,25 @@ const html = <T>(literals: TemplateStringsArray, ...values: (Values<T> | Values<
|
|
|
13
15
|
clone = cloneNode.call(fragment, true);
|
|
14
16
|
|
|
15
17
|
if (slots !== null) {
|
|
16
|
-
let
|
|
18
|
+
let e, p;
|
|
17
19
|
|
|
18
20
|
for (let i = slots.length - 1; i >= 0; i--) {
|
|
19
|
-
let { fn, path } = slots[i];
|
|
21
|
+
let { fn, name, path } = slots[i];
|
|
20
22
|
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
+
if (p !== path) {
|
|
24
|
+
e = clone;
|
|
23
25
|
|
|
24
26
|
for (let i = 0, n = path.length; i < n; i++) {
|
|
25
|
-
|
|
27
|
+
e = path[i].call(e);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
if (name === null) {
|
|
32
|
+
(fn as typeof attributes.spread | typeof slot)(e, values[i] as any);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
(fn as typeof attributes.set)(e, name, values[i]);
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
|