revert(compiler): preserve inline structured component props
This commit is contained in:
@@ -742,13 +742,6 @@ function renderNestedComponentInvocation(
|
|||||||
return ` ${attr.name}`;
|
return ` ${attr.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/^\s*\{\{[\s\S]*\}\}\s*$/.test(attr.value)) {
|
|
||||||
throw new Error(
|
|
||||||
`WRN-PROP-INLINE-OBJECT: '${attr.name}' uses an inline object or array prop. ` +
|
|
||||||
`Hoist it to state and pass ${attr.name}={yourState} instead.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const wholeExpression = wholeAttributeExpression(attr.value);
|
const wholeExpression = wholeAttributeExpression(attr.value);
|
||||||
|
|
||||||
const compiledValue = wholeExpression
|
const compiledValue = wholeExpression
|
||||||
|
|||||||
@@ -1083,19 +1083,6 @@ page Home {
|
|||||||
|
|
||||||
expect(output).toContain("__wrnexusPropAttr([");
|
expect(output).toContain("__wrnexusPropAttr([");
|
||||||
});
|
});
|
||||||
test("rejects inline object props with a hoisting diagnostic", () => {
|
|
||||||
expect(() =>
|
|
||||||
generate(
|
|
||||||
parse(`component Example { view { <Child items={{ a: 1 }} /> } }`),
|
|
||||||
),
|
|
||||||
).toThrow("WRN-PROP-INLINE-OBJECT");
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
generate(
|
|
||||||
parse(`component Example { state items = [{ a: 1 }] view { <Child items={items} /> } }`),
|
|
||||||
),
|
|
||||||
).not.toThrow();
|
|
||||||
});
|
|
||||||
test("component functions are available during server rendering", () => {
|
test("component functions are available during server rendering", () => {
|
||||||
const output = generate(
|
const output = generate(
|
||||||
parse(`
|
parse(`
|
||||||
|
|||||||
Reference in New Issue
Block a user