Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vanjs-jsx] style property no more handled #328

Open
damienflament opened this issue May 19, 2024 · 1 comment
Open

[vanjs-jsx] style property no more handled #328

damienflament opened this issue May 19, 2024 · 1 comment

Comments

@damienflament
Copy link

The style property is no more added to the resulting HTML elements.

Previously, the style property was handled differently:

export const jsx = (jsxTag, { children, style, ref, ...props }) => {
if (typeof jsxTag === "string") {
const ele = van.tags[jsxTag](mergeStyle(props, style), children);
if (ref != null) {

But now, it should be handled like the other properties:

const createElement = (jsxTag, { children, style, ref, ...props }) => {
if (typeof jsxTag === "string") {
// TODO VanNode to VanElement
const ele = van.tags[jsxTag](children);
for (const [key, value] of Object.entries(props ?? {})) {

export const setAttribute = (element, key, value) => {
// Convert Style Object
if (key === "style") {
const attr = styleToString(value);
element.setAttribute(key, attr);
return;

The point is that the style property is not in the props array because of destructuring in the createElement parameters.

As the style parameter is no more used in the current implementation, it should be left in the properties array. It will be correctly handled by the setAttribute function.

@damienflament
Copy link
Author

damienflament commented May 19, 2024

I'm preparing a pull request to fix some issues, including this one.

See https://github.com/damienflament/van/tree/jsx-fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant