Merge pull request #282 from filippomuscolino/fix/table-width
Fix: table width in percentage should include '%'
This commit is contained in:
@ -15,6 +15,7 @@ class TableWidthAttributes extends XmlAttributeComponent<ITableWidth> {
|
|||||||
export class PreferredTableWidth extends XmlComponent {
|
export class PreferredTableWidth extends XmlComponent {
|
||||||
constructor(type: WidthType, w: number) {
|
constructor(type: WidthType, w: number) {
|
||||||
super("w:tblW");
|
super("w:tblW");
|
||||||
this.root.push(new TableWidthAttributes({ type, w }));
|
const width: number | string = type === WidthType.PERCENTAGE ? `${w}%` : w;
|
||||||
|
this.root.push(new TableWidthAttributes({ type: type, w: width }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ describe("Table", () => {
|
|||||||
.which.is.an("array")
|
.which.is.an("array")
|
||||||
.with.has.length.at.least(1);
|
.with.has.length.at.least(1);
|
||||||
expect(tree["w:tbl"][0]).to.deep.equal({
|
expect(tree["w:tbl"][0]).to.deep.equal({
|
||||||
"w:tblPr": [DEFAULT_TABLE_PROPERTIES, { "w:tblW": [{ _attr: { "w:type": "pct", "w:w": 1000 } }] }],
|
"w:tblPr": [DEFAULT_TABLE_PROPERTIES, { "w:tblW": [{ _attr: { "w:type": "pct", "w:w": "1000%" } }] }],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user