@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vibe
2
2
 
3
- **Version 4.2.0** — 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`).
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ape-egg/vibe",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "type": "module",
5
5
  "description": "Runtime-first reactivity for plain HTML \u2014 no build step, no virtual DOM, no new syntax to learn",
6
6
  "main": "index.js",
@@ -1,4 +1,4 @@
1
- export const VERSION = '4.2.0';
1
+ export const VERSION = '4.2.1';
2
2
 
3
3
  export const DEBUGGER_NAME = '[vibe-debug]:';
4
4
  export const FOUC_CLASS_OR_ATTR = 'vibe-fouc';
@@ -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
- if (!DOM_PROPERTIES.includes(attr.name)) continue;
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: attr.name, expr });
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);