nexa-compiler 0.7.5 → 0.7.6
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/dist/codegen/render.js +1 -1
- package/dist/transform/template.js +23 -3
- package/package.json +1 -1
package/dist/codegen/render.js
CHANGED
|
@@ -181,7 +181,7 @@ export function generateComponentCode(sfc, filename) {
|
|
|
181
181
|
const componentBindings = renderBindings.map(b => /^[A-Z]/.test(b) ? `${b}: _ntc_${b}` : b);
|
|
182
182
|
const allRenderBindings = [...componentBindings, ...usedBuiltIns.map(b => `${b}: _ntc_${b}`)];
|
|
183
183
|
if (allRenderBindings.length > 0) {
|
|
184
|
-
lines.push(`
|
|
184
|
+
lines.push(` let { ${allRenderBindings.join(', ')} } = ctx`);
|
|
185
185
|
}
|
|
186
186
|
lines.push(generateRenderCode(sfc.template, scopeId || undefined));
|
|
187
187
|
lines.push('}');
|
|
@@ -156,9 +156,29 @@ function genProps(attrs, tag) {
|
|
|
156
156
|
const parts_name = propName.split('.');
|
|
157
157
|
const realName = parts_name[0];
|
|
158
158
|
const modifiers = parts_name.slice(1);
|
|
159
|
-
let handler
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
let handler;
|
|
160
|
+
if (typeof attr.value === 'string' && /^\w+$/.test(attr.value)) {
|
|
161
|
+
handler = attr.value;
|
|
162
|
+
}
|
|
163
|
+
else if (typeof attr.value === 'string') {
|
|
164
|
+
const eqIdx = attr.value.indexOf('=');
|
|
165
|
+
if (eqIdx > 0) {
|
|
166
|
+
const lhs = attr.value.slice(0, eqIdx).trim();
|
|
167
|
+
const rhs = attr.value.slice(eqIdx + 1).trim();
|
|
168
|
+
if (/^[a-zA-Z_$]\w*$/.test(lhs)) {
|
|
169
|
+
handler = `($event) => { ${lhs}.value = ${rhs} }`;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
handler = `($event) => { ${attr.value} }`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
handler = `($event) => { ${attr.value} }`;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
handler = `($event) => { ${attr.value} }`;
|
|
181
|
+
}
|
|
162
182
|
const keyMap = {
|
|
163
183
|
enter: 'Enter', esc: 'Escape', tab: 'Tab',
|
|
164
184
|
space: ' ', up: 'ArrowUp', down: 'ArrowDown',
|