@ape-egg/vibe 4.2.0 → 4.2.1
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/README.md +1 -1
- package/package.json +1 -1
- package/runtime/constants.js +1 -1
- package/runtime/iterate.js +14 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vibe
|
|
2
2
|
|
|
3
|
-
**Version 4.2.
|
|
3
|
+
**Version 4.2.1** — Runtime-first reactivity for plain HTML. Drop a script tag into any page and get reactive bindings, control flow, and URL-loaded components — no build step required. Compile later if you want; the compiler is a separate, optional package (`@ape-egg/vibe-compiler`).
|
|
4
4
|
|
|
5
5
|
## Security model & CSP
|
|
6
6
|
|
package/package.json
CHANGED
package/runtime/constants.js
CHANGED
package/runtime/iterate.js
CHANGED
|
@@ -23,6 +23,8 @@ import {
|
|
|
23
23
|
ITER_PROP_PATH,
|
|
24
24
|
COMPONENT_ID_ATTR,
|
|
25
25
|
COMPONENT_SRC_SELECTOR,
|
|
26
|
+
DEFER_ATTR_PREFIX,
|
|
27
|
+
INTERNAL_ATTR_PREFIX,
|
|
26
28
|
} from './constants.js';
|
|
27
29
|
|
|
28
30
|
import * as compiled from './pre-compiled-iterations.js';
|
|
@@ -71,6 +73,14 @@ const BATCH_ATTR_BINDING_REGEX = new RegExp(
|
|
|
71
73
|
String.raw`(\s)([\w-]+)="@\[(${BATCH_BINDING_INNER})\]"`,
|
|
72
74
|
'g',
|
|
73
75
|
);
|
|
76
|
+
const DEFERRED_ATTR_REGEX = new RegExp(
|
|
77
|
+
String.raw`(\s)${DEFER_ATTR_PREFIX}(?!${INTERNAL_ATTR_PREFIX.slice(DEFER_ATTR_PREFIX.length)})(?=[\w-])`,
|
|
78
|
+
'g',
|
|
79
|
+
);
|
|
80
|
+
const realAttrName = (name) =>
|
|
81
|
+
name.startsWith(DEFER_ATTR_PREFIX) && !name.startsWith(INTERNAL_ATTR_PREFIX)
|
|
82
|
+
? name.slice(DEFER_ATTR_PREFIX.length)
|
|
83
|
+
: name;
|
|
74
84
|
|
|
75
85
|
const mapTagSpans = (html, fn) => {
|
|
76
86
|
let out = '';
|
|
@@ -131,13 +141,14 @@ export const compileBatchFn = (template, itemAlias, indexAlias, stateKeys, ancho
|
|
|
131
141
|
const attrs = [...el.attributes];
|
|
132
142
|
for (let a = 0; a < attrs.length; a++) {
|
|
133
143
|
const attr = attrs[a];
|
|
134
|
-
|
|
144
|
+
const prop = realAttrName(attr.name);
|
|
145
|
+
if (!DOM_PROPERTIES.includes(prop)) continue;
|
|
135
146
|
const m = attr.value.match(PURE_BINDING_REGEX);
|
|
136
147
|
if (!m) continue;
|
|
137
148
|
let expr = m[1];
|
|
138
149
|
if (componentId) expr = expr.replace(THIS_PROP_REGEX, `$['${componentId}'].$1`);
|
|
139
150
|
indexes.push(domPropertyWrites.length);
|
|
140
|
-
domPropertyWrites.push({ prop
|
|
151
|
+
domPropertyWrites.push({ prop, expr });
|
|
141
152
|
}
|
|
142
153
|
if (indexes.length > 0) {
|
|
143
154
|
el.setAttribute(BATCH_ATTR, indexes.join(','));
|
|
@@ -172,7 +183,7 @@ export const compileBatchFn = (template, itemAlias, indexAlias, stateKeys, ancho
|
|
|
172
183
|
let code = escaped;
|
|
173
184
|
|
|
174
185
|
let needsCiWalker = false;
|
|
175
|
-
code = mapTagSpans(code, (tag) => tag.replace(BATCH_NAME_BINDING_REGEX, (_, _ws, expr) => {
|
|
186
|
+
code = mapTagSpans(code, (tag) => tag.replace(DEFERRED_ATTR_REGEX, '$1').replace(BATCH_NAME_BINDING_REGEX, (_, _ws, expr) => {
|
|
176
187
|
let decExpr = decodeEntities(expr);
|
|
177
188
|
if (decExpr.includes('[') || decExpr.includes('(')) {
|
|
178
189
|
return nameBindingEmit(decExpr);
|