Skip to content

Commit

Permalink
Add support for tables w/o align
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 18, 2020
1 parent 84c85f7 commit c3e033d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/handlers/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var all = require('../all')
function table(h, node) {
var rows = node.children
var index = rows.length
var align = node.align
var align = node.align || []
var alignLength = align.length
var result = []
var pos
Expand All @@ -21,7 +21,7 @@ function table(h, node) {
while (index--) {
row = rows[index].children
name = index === 0 ? 'th' : 'td'
pos = alignLength
pos = alignLength || row.length
out = []

while (pos--) {
Expand Down
6 changes: 3 additions & 3 deletions test/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test('Table', function (t) {

t.deepEqual(
to(
u('table', {align: ['left', 'right']}, [
u('table', [
u('tableRow', [
u('tableCell', [u('text', 'a')]),
u('tableCell', [u('text', 'b')])
Expand All @@ -73,11 +73,11 @@ test('Table', function (t) {
u('text', '\n'),
u('element', {tagName: 'tr', properties: {}}, [
u('text', '\n'),
u('element', {tagName: 'th', properties: {align: 'left'}}, [
u('element', {tagName: 'th', properties: {align: undefined}}, [
u('text', 'a')
]),
u('text', '\n'),
u('element', {tagName: 'th', properties: {align: 'right'}}, [
u('element', {tagName: 'th', properties: {align: undefined}}, [
u('text', 'b')
]),
u('text', '\n')
Expand Down

0 comments on commit c3e033d

Please sign in to comment.