@mulanjs/mulanjs 1.0.1-dev.20260302074037 → 1.0.1-dev.20260305165012
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.
|
@@ -248,7 +248,12 @@ function generateDOMInstruction(node, chunks, getUid, getHoistId, hoists, uidRef
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
else if (key === 'id') {
|
|
251
|
-
|
|
251
|
+
if (value.includes('${')) {
|
|
252
|
+
chunks.push(`this._bindEffect(() => { if (${id}) ${id}.id = _va("id", \`${value}\`); }, ${id});`);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
chunks.push(`if (${id}) ${id}.id = _va("id", ${JSON.stringify(value)});`);
|
|
256
|
+
}
|
|
252
257
|
}
|
|
253
258
|
else if (key === 'data-mu-id') {
|
|
254
259
|
// Ignore internal string compiler metadata
|
|
@@ -362,6 +367,11 @@ function transform(node, scriptResult, scopedId, localScope = [], filename) {
|
|
|
362
367
|
domBindings.push({ type: 'event', name: eventName, expr });
|
|
363
368
|
delete element.props[key];
|
|
364
369
|
}
|
|
370
|
+
else {
|
|
371
|
+
if (typeof element.props[key] === 'string' && element.props[key].includes('${')) {
|
|
372
|
+
element.props[key] = element.props[key].replace(/\$\{(.*?)\}/g, (_, expr) => '${' + processBindings(expr, scriptResult.bindings, localScope) + '}');
|
|
373
|
+
}
|
|
374
|
+
}
|
|
365
375
|
}
|
|
366
376
|
element.children.forEach(child => transform(child, scriptResult, scopedId, childScope, filename));
|
|
367
377
|
}
|
package/package.json
CHANGED
|
@@ -301,7 +301,11 @@ function generateDOMInstruction(node: Node, chunks: string[], getUid: () => stri
|
|
|
301
301
|
chunks.push(`if (${id}) ${id}.className = _va("class", ${JSON.stringify(value)});`);
|
|
302
302
|
}
|
|
303
303
|
} else if (key === 'id') {
|
|
304
|
-
|
|
304
|
+
if (value.includes('${')) {
|
|
305
|
+
chunks.push(`this._bindEffect(() => { if (${id}) ${id}.id = _va("id", \`${value}\`); }, ${id});`);
|
|
306
|
+
} else {
|
|
307
|
+
chunks.push(`if (${id}) ${id}.id = _va("id", ${JSON.stringify(value)});`);
|
|
308
|
+
}
|
|
305
309
|
} else if (key === 'data-mu-id') {
|
|
306
310
|
// Ignore internal string compiler metadata
|
|
307
311
|
} else {
|
|
@@ -417,6 +421,10 @@ function transform(node: Node, scriptResult: ScriptCompileResult, scopedId?: str
|
|
|
417
421
|
const expr = (bound.includes('(') || bound.includes('=') || bound.includes('++')) ? `($event) => { ${bound.replace(/`/g, '\\`')} }` : bound;
|
|
418
422
|
domBindings.push({ type: 'event', name: eventName, expr });
|
|
419
423
|
delete element.props[key];
|
|
424
|
+
} else {
|
|
425
|
+
if (typeof element.props[key] === 'string' && element.props[key].includes('${')) {
|
|
426
|
+
element.props[key] = element.props[key].replace(/\$\{(.*?)\}/g, (_: any, expr: string) => '${' + processBindings(expr, scriptResult.bindings, localScope) + '}');
|
|
427
|
+
}
|
|
420
428
|
}
|
|
421
429
|
}
|
|
422
430
|
element.children.forEach(child => transform(child, scriptResult, scopedId, childScope, filename));
|