Skip to content

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

@damienflament

Description

@damienflament

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions