Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

valign is not being transformed #11

Open
TheComp44 opened this issue Sep 3, 2021 · 2 comments · May be fixed by #12
Open

valign is not being transformed #11

TheComp44 opened this issue Sep 3, 2021 · 2 comments · May be fixed by #12

Comments

@TheComp44
Copy link

HAST transforms property names with acronyms into camelcased names:

Acronyms in names are treated as a normal word and the previous rules apply. For example, itemid become itemId and bgcolor becomes bgColor.

Likewise, valign becomes vAlign in a HAST, but the plugin only checks for the lowercase property name, which misses on all HASTs.

This is a problem when using rehype-react as react complains about the unknownvAlign prop which is passed on to the component.

@TheComp44 TheComp44 linked a pull request Sep 6, 2021 that will close this issue
@TheComp44
Copy link
Author

I've just checked and the tests seem to be failing for the PR, but I think the problem is with rehype-parse. I think it uses the svg namespace for the tests for some reason, which doesn't transform property names.

But I have tested with both rehype-dom-parse (in the browser) as well as using hastscript directly and both are transforming property names according to the HAST spec:

import { h } from "hastscript";
import tableCellStyle from "@mapbox/hast-util-table-cell-style";

console.log(tableCellStyle(h("td", { valign: "top", align: "left" })));

yields:

{
  type: 'element',
  tagName: 'td',
  properties: { vAlign: 'top', style: 'text-align: left;' },
  children: []
}

@TheComp44
Copy link
Author

I was wrong. The tests just used an outdated version of unified, rehype-parse and rehype-stringify. Should update those dependencies, but then the tests have to be rewritten to support ESmodules as unified can't be required anymore.

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

Successfully merging a pull request may close this issue.

1 participant