Skip to content

fix(table): support unit-less and none CSS border values - #333

Open
s1reyash wants to merge 1 commit into
privateOmega:developfrom
s1reyash:fix/52-table-border-unitless
Open

s1reyash wants to merge 1 commit into
privateOmega:developfrom
s1reyash:fix/52-table-border-unitless

Conversation

@s1reyash

Copy link
Copy Markdown

Summary

  • Updated cssBorderParser in src/helpers/xml-builder/fixups.ts to parse unit-less 0 and none as [0, 'none', undefined] and unit-less numeric widths as pixel values.
  • Updated table.ts so border: 0 / border: '0' is preserved (not overridden by the default borderSize = 2 via ||) on both tables and table cells.
  • Added unit tests in tests/table-border.test.js.

Verification

  • npm test: 10 test files passed

Fixes #52

@privateOmega
privateOmega changed the base branch from master to develop November 28, 2026 15:33
@privateOmega

Copy link
Copy Markdown
Owner

Thanks @s1reyash! develop is now the default branch, and work lands there before release, so I've switched this PR's base from master to develop. It still merges cleanly. I'll review it shortly.

@privateOmega privateOmega left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this works. I ran it merged with current develop: border: 0, border: none and border: 0px on a table and its cells now give no borders, where develop wrote w:sz="0" single borders. border: 1px solid red is unchanged. Typecheck, lint and all tests pass.

One thing before it can merge:

  • Formatting: pnpm exec oxfmt --check . fails on src/helpers/xml-builder/fixups.ts (the long stroke = … line). pnpm format fixes it. CI hasn't run on this PR yet because it's from a fork; it will after this push.

Optional, but nice:

  • An end-to-end test next to the unit tests, e.g. converting <table style="border: 0"><tr><td>a</td></tr></table> and checking the document has no <w:tblBorders> sides with a width. That locks in the user-visible behaviour from #52, not just the parser.

(#177 is a different bug: continued cells of a rowspan get default borders. So this PR shouldn't close it, which matches your Fixes #52.)

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

Table border - should honor unit-less or abbreviated strings or individual css border properties

2 participants