diff --git a/src/compiler/code_generator.ts b/src/compiler/code_generator.ts index 195563ea..69c2d2f9 100644 --- a/src/compiler/code_generator.ts +++ b/src/compiler/code_generator.ts @@ -967,7 +967,7 @@ export class CodeGenerator { const props: string[] = []; let hasSlotsProp = false; for (let p in ast.props) { - const propName = p.includes("-") ? `'${p}'` : p; + const propName = /^[a-z_]+$/i.test(p) ? p : `'${p}'`; props.push(`${propName}: ${this.captureExpression(ast.props[p]) || undefined}`); if (p === "slots") { hasSlotsProp = true; diff --git a/tests/components/__snapshots__/props.test.ts.snap b/tests/components/__snapshots__/props.test.ts.snap index ea2bcbef..235debe3 100644 --- a/tests/components/__snapshots__/props.test.ts.snap +++ b/tests/components/__snapshots__/props.test.ts.snap @@ -123,6 +123,33 @@ exports[`basics prop names can contain - 2`] = ` }" `; +exports[`basics support prop names that aren't valid bare object property names 1`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + let block1 = createBlock(\`